r196627 - Fixing assertion failure introduced in 196602.

Warren Hunt whunt at google.com
Fri Dec 6 16:15:04 PST 2013


Author: whunt
Date: Fri Dec  6 18:15:04 2013
New Revision: 196627

URL: http://llvm.org/viewvc/llvm-project?rev=196627&view=rev
Log:
Fixing assertion failure introduced in 196602.

Also includes a minor refactor with no functional change.


Modified:
    cfe/trunk/include/clang/AST/RecordLayout.h
    cfe/trunk/lib/AST/RecordLayoutBuilder.cpp

Modified: cfe/trunk/include/clang/AST/RecordLayout.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecordLayout.h?rev=196627&r1=196626&r2=196627&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/RecordLayout.h (original)
+++ cfe/trunk/include/clang/AST/RecordLayout.h Fri Dec  6 18:15:04 2013
@@ -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 {

Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=196627&r1=196626&r2=196627&view=diff
==============================================================================
--- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Fri Dec  6 18:15:04 2013
@@ -2590,15 +2590,13 @@ void MicrosoftRecordLayoutBuilder::layou
   // 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;
 }





More information about the cfe-commits mailing list