]> granicus.if.org Git - clang/commitdiff
Fixing assertion failure introduced in 196602.
authorWarren Hunt <whunt@google.com>
Sat, 7 Dec 2013 00:15:04 +0000 (00:15 +0000)
committerWarren Hunt <whunt@google.com>
Sat, 7 Dec 2013 00:15:04 +0000 (00:15 +0000)
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
lib/AST/RecordLayoutBuilder.cpp

index 1eae8c057ca77ad7abfb1c5e9357e67393a50579..ca1071804491d7e92c8021635872517bc47c6165 100644 (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 {
index b692025aa0fdc07b9fa42ef6d372692a3bdbfea3..a3ea6b9f3861ab7d7c799caa6502e893d4674a22 100644 (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;
 }