]> granicus.if.org Git - clang/commitdiff
Fux a bug where we were trying to add overriders for non-virtual bases of virtual...
authorAnders Carlsson <andersca@mac.com>
Thu, 25 Feb 2010 22:18:35 +0000 (22:18 +0000)
committerAnders Carlsson <andersca@mac.com>
Thu, 25 Feb 2010 22:18:35 +0000 (22:18 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97173 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGVtable.cpp
test/CodeGenCXX/vtable-layout.cpp

index 5ebe816068f8f449e87f22ea6e60525312c773d5..a6b8eb6d3d42e14b5489d8382aaaa80ac9e6f992 100644 (file)
@@ -261,10 +261,10 @@ static BaseOffset ComputeBaseOffset(ASTContext &Context,
     
     // Check the base class offset.
     const ASTRecordLayout &Layout = Context.getASTRecordLayout(Element.Class);
-    
+
     const RecordType *BaseType = Element.Base->getType()->getAs<RecordType>();
     const CXXRecordDecl *Base = cast<CXXRecordDecl>(BaseType->getDecl());
-    
+
     NonVirtualOffset += Layout.getBaseClassOffset(Base);
   }
   
@@ -512,7 +512,7 @@ void FinalOverriders::ComputeFinalOverriders(BaseSubobject Base,
     if (!BaseDecl->isPolymorphic())
       continue;
     
-    bool IsVisitedVirtualBase = false;
+    bool IsVisitedVirtualBase = BaseSubobjectIsVisitedVBase;
     uint64_t BaseOffset;
     if (I->isVirtual()) {
       if (!VisitedVirtualBases.insert(BaseDecl))
index efd0d2f7bcd57f44662e4f4b71ad7251e4f64d93..c22222f9ce3d3b85f3ba60192c8cea83ce485e33 100644 (file)
@@ -510,3 +510,32 @@ void C::f() { }
 
 }
 
+namespace Test14 {
+
+// Verify that we handle A being a non-virtual base of B, which is a virtual base.
+
+struct A { 
+  virtual void f(); 
+};
+
+struct B : A { };
+
+struct C : virtual B { };
+
+// CHECK:      Vtable for 'Test14::D' (5 entries).
+// CHECK-NEXT:    0 | vbase_offset (0)
+// CHECK-NEXT:    1 | vcall_offset (0)
+// CHECK-NEXT:    2 | offset_to_top (0)
+// CHECK-NEXT:    3 | Test14::D RTTI
+// CHECK-NEXT:        -- (Test14::A, 0) vtable address --
+// CHECK-NEXT:        -- (Test14::B, 0) vtable address --
+// CHECK-NEXT:        -- (Test14::C, 0) vtable address --
+// CHECK-NEXT:        -- (Test14::D, 0) vtable address --
+// CHECK-NEXT:    4 | void Test14::D::f()
+struct D : C, virtual B {
+ virtual void f();
+};
+void D::f() { }
+
+}
+