summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-08-24 23:43:39 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-08-24 23:43:39 +0000
commit24adaee6bc305b69200c7c022b63fe4a414f6502 (patch)
tree5f01a13f18a7b9a99f940b04d5487168aa84898d /clang
parent12cda3384abf8fc077bdea86ec797f2c8027ca76 (diff)
downloadbcm5719-llvm-24adaee6bc305b69200c7c022b63fe4a414f6502.tar.gz
bcm5719-llvm-24adaee6bc305b69200c7c022b63fe4a414f6502.zip
Fix integer unsigned behavior in clang due to signed left shift overflow.
llvm-svn: 162626
Diffstat (limited to 'clang')
-rw-r--r--clang/include/clang/AST/VTableBuilder.h5
-rw-r--r--clang/lib/CodeGen/CGRTTI.cpp2
2 files changed, 4 insertions, 3 deletions
diff --git a/clang/include/clang/AST/VTableBuilder.h b/clang/include/clang/AST/VTableBuilder.h
index 392dad94a4a..a6aa40b9d68 100644
--- a/clang/include/clang/AST/VTableBuilder.h
+++ b/clang/include/clang/AST/VTableBuilder.h
@@ -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) {
diff --git a/clang/lib/CodeGen/CGRTTI.cpp b/clang/lib/CodeGen/CGRTTI.cpp
index eca9f5b16be..e46423b95ae 100644
--- a/clang/lib/CodeGen/CGRTTI.cpp
+++ b/clang/lib/CodeGen/CGRTTI.cpp
@@ -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.
OpenPOWER on IntegriCloud