summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenCXX/vtable-layout.cpp
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2010-02-12 05:25:12 +0000
committerAnders Carlsson <andersca@mac.com>2010-02-12 05:25:12 +0000
commit65b4978f7f81a456425049d5f11ad0b65c7ce91d (patch)
tree7c48e4f0d06021b24edc7834e3b3668f273fcd67 /clang/test/CodeGenCXX/vtable-layout.cpp
parent62d5d64ce962e7bc39e9ecd90a6ba05806aa2c90 (diff)
downloadbcm5719-llvm-65b4978f7f81a456425049d5f11ad0b65c7ce91d.tar.gz
bcm5719-llvm-65b4978f7f81a456425049d5f11ad0b65c7ce91d.zip
More work on vtable layout. We can now layout vtables with primary bases.
llvm-svn: 95965
Diffstat (limited to 'clang/test/CodeGenCXX/vtable-layout.cpp')
-rw-r--r--clang/test/CodeGenCXX/vtable-layout.cpp61
1 files changed, 58 insertions, 3 deletions
diff --git a/clang/test/CodeGenCXX/vtable-layout.cpp b/clang/test/CodeGenCXX/vtable-layout.cpp
index 3f7e18a0955..f7db2135d2f 100644
--- a/clang/test/CodeGenCXX/vtable-layout.cpp
+++ b/clang/test/CodeGenCXX/vtable-layout.cpp
@@ -9,8 +9,8 @@ namespace Test1 {
struct A {
virtual void f();
};
-
void A::f() { }
+
}
namespace Test2 {
@@ -36,10 +36,10 @@ struct A {
virtual void h();
virtual A& operator=(const A&);
};
-
void A::f() { }
// Another simple vtable dumper test.
+
// CHECK: Vtable for 'Test2::B' (6 entries).
// CHECK-NEXT: 0 | offset_to_top (0)
// CHECK-NEXT: 1 | Test2::B RTTI
@@ -48,13 +48,68 @@ void A::f() { }
// CHECK-NEXT: 3 | void Test2::B::g() [pure]
// CHECK-NEXT: 4 | Test2::B::~B() [complete] [pure]
// CHECK-NEXT: 5 | Test2::B::~B() [deleting] [pure]
-
struct B {
virtual void f();
virtual void g() = 0;
virtual ~B() = 0;
};
+void B::f() { }
+
+}
+
+namespace Test3 {
+// If a function in a derived class overrides a function in a primary base,
+// then the function should not have an entry in the derived class (unless the return
+// value requires adjusting).
+
+// CHECK: Vtable for 'Test3::A' (3 entries).
+// CHECK-NEXT: 0 | offset_to_top (0)
+// CHECK-NEXT: 1 | Test3::A RTTI
+// CHECK-NEXT: -- (Test3::A, 0) vtable address --
+// CHECK-NEXT: 2 | void Test3::A::f()
+struct A {
+ virtual void f();
+};
+void A::f() { }
+
+// CHECK: Vtable for 'Test3::B' (4 entries).
+// CHECK-NEXT: 0 | offset_to_top (0)
+// CHECK-NEXT: 1 | Test3::B RTTI
+// CHECK-NEXT: -- (Test3::B, 0) vtable address --
+// CHECK-NEXT: 2 | void Test3::A::f()
+// CHECK-NEXT: 3 | void Test3::B::g()
+struct B : A {
+ virtual void f();
+ virtual void g();
+};
void B::f() { }
+// CHECK: Vtable for 'Test3::C' (5 entries).
+// CHECK-NEXT: 0 | offset_to_top (0)
+// CHECK-NEXT: 1 | Test3::C RTTI
+// CHECK-NEXT: -- (Test3::C, 0) vtable address --
+// CHECK-NEXT: 2 | void Test3::A::f()
+// CHECK-NEXT: 3 | void Test3::C::g()
+// CHECK-NEXT: 4 | void Test3::C::h()
+struct C : A {
+ virtual void g();
+ virtual void h();
+};
+void C::g() { }
+
+// CHECK: Vtable for 'Test3::D' (5 entries).
+// CHECK-NEXT: 0 | offset_to_top (0)
+// CHECK-NEXT: 1 | Test3::D RTTI
+// CHECK-NEXT: -- (Test3::D, 0) vtable address --
+// CHECK-NEXT: 2 | void Test3::A::f()
+// CHECK-NEXT: 3 | void Test3::B::g()
+// CHECK-NEXT: 4 | void Test3::D::h()
+struct D : B {
+ virtual void f();
+ virtual void g();
+ virtual void h();
+};
+
+void D::f() { }
}
OpenPOWER on IntegriCloud