[cfe-commits] r97173 - in /cfe/trunk: lib/CodeGen/CGVtable.cpp test/CodeGenCXX/vtable-layout.cpp

Anders Carlsson andersca at mac.com
Thu Feb 25 14:18:35 PST 2010


Author: andersca
Date: Thu Feb 25 16:18:35 2010
New Revision: 97173

URL: http://llvm.org/viewvc/llvm-project?rev=97173&view=rev
Log:
Fux a bug where we were trying to add overriders for non-virtual bases of virtual bases more than once.

Modified:
    cfe/trunk/lib/CodeGen/CGVtable.cpp
    cfe/trunk/test/CodeGenCXX/vtable-layout.cpp

Modified: cfe/trunk/lib/CodeGen/CGVtable.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVtable.cpp?rev=97173&r1=97172&r2=97173&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGVtable.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVtable.cpp Thu Feb 25 16:18:35 2010
@@ -261,10 +261,10 @@
     
     // 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 @@
     if (!BaseDecl->isPolymorphic())
       continue;
     
-    bool IsVisitedVirtualBase = false;
+    bool IsVisitedVirtualBase = BaseSubobjectIsVisitedVBase;
     uint64_t BaseOffset;
     if (I->isVirtual()) {
       if (!VisitedVirtualBases.insert(BaseDecl))

Modified: cfe/trunk/test/CodeGenCXX/vtable-layout.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/vtable-layout.cpp?rev=97173&r1=97172&r2=97173&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/vtable-layout.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/vtable-layout.cpp Thu Feb 25 16:18:35 2010
@@ -510,3 +510,32 @@
 
 }
 
+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() { }
+
+}
+





More information about the cfe-commits mailing list