TableGen: Avoid undefined behaviour by doing this shift in int64
[oota-llvm.git] / lib / TableGen / Record.cpp
index 7229b8c30a39197494f4d95f191f0735eef0d62c..1b5a902dea689b035932327343f2254a9abcddf5 100644 (file)
@@ -230,7 +230,7 @@ Init *IntRecTy::convertValue(BitsInit *BI) {
   int64_t Result = 0;
   for (unsigned i = 0, e = BI->getNumBits(); i != e; ++i)
     if (BitInit *Bit = dyn_cast<BitInit>(BI->getBit(i)))
-      Result |= Bit->getValue() << i;
+      Result |= static_cast<int64_t>(Bit->getValue()) << i;
     else
       return nullptr;
   return IntInit::get(Result);