Fix integer unsigned behavior in clang due to signed left shift overflow.

llvm-svn: 162626
This commit is contained in:
Richard Smith 2012-08-24 23:43:39 +00:00
parent 12cda3384a
commit 24adaee6bc
2 changed files with 4 additions and 3 deletions

View 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) {

View 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.