Fixing assertion failure introduced in 196602.

Also includes a minor refactor with no functional change.

llvm-svn: 196627
This commit is contained in:
Warren Hunt
2013-12-07 00:15:04 +00:00
parent 4e8656077c
commit 4aafaee7df
2 changed files with 5 additions and 8 deletions
+1 -2
View File
@@ -283,8 +283,7 @@ public:
}
bool hasZeroSizedSubObject() const {
assert(CXXInfo && "Record layout does not have C++ specific info!");
return CXXInfo->HasZeroSizedSubObject;
return CXXInfo && CXXInfo->HasZeroSizedSubObject;
}
bool leadsWithZeroSizedBase() const {
+4 -6
View File
@@ -2590,15 +2590,13 @@ void MicrosoftRecordLayoutBuilder::layoutVirtualBase(const CXXRecordDecl *RD,
// vtordisps are always 4 bytes (even in 64-bit mode)
if (HasVtordisp)
Size = Size.RoundUpToAlignment(Alignment) + CharUnits::fromQuantity(4);
Size = Size.RoundUpToAlignment(BaseAlign);
// Insert the base here.
CharUnits BaseOffset = Size.RoundUpToAlignment(BaseAlign);
Size = Size.RoundUpToAlignment(BaseAlign);
VBases.insert(
std::make_pair(RD, ASTRecordLayout::VBaseInfo(BaseOffset, HasVtordisp)));
Size = BaseOffset + BaseNVSize;
// Note: we don't update alignment here because it was accounted for in
// InitializeLayout.
std::make_pair(RD, ASTRecordLayout::VBaseInfo(Size, HasVtordisp)));
Size += BaseNVSize;
// Alignment was upadated in InitializeCXXLayout.
PreviousBaseLayout = &Layout;
}