mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-27 04:18:42 +00:00
TableGen: Avoid undefined behaviour by doing this shift in int64
Found by ubsan. This was taking a bool and left shifting by 32 - the result is 64 bit, so we should really do the math in a type it fits in. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237345 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
1 parent
bed1965111
commit
f8ca978417
1 file changed
+1
-1
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user