]> granicus.if.org Git - clang/commitdiff
Fix another vbase layout bug.
authorAnders Carlsson <andersca@mac.com>
Sat, 10 Apr 2010 21:35:33 +0000 (21:35 +0000)
committerAnders Carlsson <andersca@mac.com>
Sat, 10 Apr 2010 21:35:33 +0000 (21:35 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100952 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/RecordLayoutBuilder.cpp
test/CodeGenCXX/vtable-layout.cpp

index b2426833a2ec688e26da7203c90a4d638c2d6864..2bc2a128f4fd03f2058de87fa77b05645da00ec7 100644 (file)
@@ -263,8 +263,12 @@ ASTRecordLayoutBuilder::LayoutVirtualBases(const CXXRecordDecl *RD,
     uint64_t BaseOffset;
 
     if (I->isVirtual()) {
+      // If we don't know this vbase yet, don't visit it. It will be visited
+      // later.
+      if (!VBases.count(Base))
+        continue;
+  
       // We want the vbase offset from the class we're currently laying out.
-      assert(VBases.count(Base) && "Did not find virtual base!");
       BaseOffset = VBases[Base];
     } else if (RD == MostDerivedClass) {
       // We want the base offset from the class we're currently laying out.
index 62e02fcea5e45241625eb0b52360468d32de0bd1..243d373d3a2d4796265e4edcc89ab9beeb933baa 100644 (file)
@@ -1364,3 +1364,26 @@ struct D : virtual C {
 void D::f() { }
 
 }
+
+namespace Test32 {
+
+// Check that we correctly lay out the virtual bases of 'Test32::D'.
+
+struct A {
+  virtual void f();
+};
+
+struct B : virtual A { };
+struct C : A, virtual B { };
+struct D : virtual B { };
+
+// CHECK:      Virtual base offset offsets for 'Test32::E' (3 entries).
+// CHECK-NEXT:    Test32::A | -32
+// CHECK-NEXT:    Test32::B | -24
+// CHECK-NEXT:    Test32::D | -40
+struct E : C, virtual D {
+  virtual void f();
+};
+void E::f() { }
+
+}