From c2f77749a5876439da1dd24c67108f1091e45e6a Mon Sep 17 00:00:00 2001 From: Warren Hunt Date: Sat, 7 Dec 2013 00:15:04 +0000 Subject: [PATCH] Fixing assertion failure introduced in 196602. Also includes a minor refactor with no functional change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196627 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/RecordLayout.h | 3 +-- lib/AST/RecordLayoutBuilder.cpp | 10 ++++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/include/clang/AST/RecordLayout.h b/include/clang/AST/RecordLayout.h index 1eae8c057c..ca10718044 100644 --- a/include/clang/AST/RecordLayout.h +++ b/include/clang/AST/RecordLayout.h @@ -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 { diff --git a/lib/AST/RecordLayoutBuilder.cpp b/lib/AST/RecordLayoutBuilder.cpp index b692025aa0..a3ea6b9f38 100644 --- a/lib/AST/RecordLayoutBuilder.cpp +++ b/lib/AST/RecordLayoutBuilder.cpp @@ -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; } -- 2.40.0