aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/CodeGen/CGVtable.cpp6
-rw-r--r--test/CodeGenCXX/vtable-layout.cpp29
2 files changed, 32 insertions, 3 deletions
diff --git a/lib/CodeGen/CGVtable.cpp b/lib/CodeGen/CGVtable.cpp
index 5ebe816068..a6b8eb6d3d 100644
--- a/lib/CodeGen/CGVtable.cpp
+++ b/lib/CodeGen/CGVtable.cpp
@@ -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))
diff --git a/test/CodeGenCXX/vtable-layout.cpp b/test/CodeGenCXX/vtable-layout.cpp
index efd0d2f7bc..c22222f9ce 100644
--- a/test/CodeGenCXX/vtable-layout.cpp
+++ b/test/CodeGenCXX/vtable-layout.cpp
@@ -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() { }
+
+}
+