summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2015-05-14 06:47:02 +0000
committerJustin Bogner <mail@justinbogner.com>2015-05-14 06:47:02 +0000
commit1a9ca774b687ebae352d8795e5a3603605408580 (patch)
tree154d5bdc82d2ba738b5a04f48a871878afa19c01 /llvm
parent02ddd7f529fa7f667365af9a6e80acb7d69a6635 (diff)
downloadbcm5719-llvm-1a9ca774b687ebae352d8795e5a3603605408580.tar.gz
bcm5719-llvm-1a9ca774b687ebae352d8795e5a3603605408580.zip
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. llvm-svn: 237345
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/TableGen/Record.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp
index 7229b8c30a3..1b5a902dea6 100644
--- a/llvm/lib/TableGen/Record.cpp
+++ b/llvm/lib/TableGen/Record.cpp
@@ -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);
OpenPOWER on IntegriCloud