]> granicus.if.org Git - clang/commitdiff
Fix integer unsigned behavior in clang due to signed left shift overflow.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 24 Aug 2012 23:43:39 +0000 (23:43 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 24 Aug 2012 23:43:39 +0000 (23:43 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162626 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/VTableBuilder.h
lib/CodeGen/CGRTTI.cpp

index 392dad94a4a31fefa8fde1d32676d34341d2d029..a6aa40b9d68b6215ae5e0886f22800f7757201e2 100644 (file)
@@ -147,9 +147,10 @@ private:
     assert((ComponentKind == CK_VCallOffset ||
             ComponentKind == CK_VBaseOffset ||
             ComponentKind == CK_OffsetToTop) && "Invalid component kind!");
-    assert(Offset.getQuantity() <= ((1LL << 56) - 1) && "Offset is too big!");
+    assert(Offset.getQuantity() < (1LL << 56) && "Offset is too big!");
+    assert(Offset.getQuantity() >= -(1LL << 56) && "Offset is too small!");
 
-    Value = ((Offset.getQuantity() << 3) | ComponentKind);
+    Value = (uint64_t(Offset.getQuantity()) << 3) | ComponentKind;
   }
 
   VTableComponent(Kind ComponentKind, uintptr_t Ptr) {
index eca9f5b16be1fe655f1c4765ba42f0556b0fe762..e46423b95ae98e5f2845ac2c803ca123b76f111d 100644 (file)
@@ -886,7 +886,7 @@ void RTTIBuilder::BuildVMIClassTypeInfo(const CXXRecordDecl *RD) {
       Offset = Layout.getBaseClassOffset(BaseDecl);
     };
     
-    OffsetFlags = Offset.getQuantity() << 8;
+    OffsetFlags = uint64_t(Offset.getQuantity()) << 8;
     
     // The low-order byte of __offset_flags contains flags, as given by the 
     // masks from the enumeration __offset_flags_masks.