From 1a9ca774b687ebae352d8795e5a3603605408580 Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Thu, 14 May 2015 06:47:02 +0000 Subject: 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 --- llvm/lib/TableGen/Record.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'llvm/lib') 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(BI->getBit(i))) - Result |= Bit->getValue() << i; + Result |= static_cast(Bit->getValue()) << i; else return nullptr; return IntInit::get(Result); -- cgit v1.2.3