diff options
author | Justin Bogner <mail@justinbogner.com> | 2015-05-14 06:47:02 +0000 |
---|---|---|
committer | Justin Bogner <mail@justinbogner.com> | 2015-05-14 06:47:02 +0000 |
commit | 1a9ca774b687ebae352d8795e5a3603605408580 (patch) | |
tree | 154d5bdc82d2ba738b5a04f48a871878afa19c01 /llvm/lib | |
parent | 02ddd7f529fa7f667365af9a6e80acb7d69a6635 (diff) | |
download | bcm5719-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/lib')
-rw-r--r-- | llvm/lib/TableGen/Record.cpp | 2 |
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); |