summaryrefslogtreecommitdiffstats
path: root/test/CodeGenCXX/vtt-layout.cpp
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2010-01-18 04:25:18 +0000
committerAnders Carlsson <andersca@mac.com>2010-01-18 04:25:18 +0000
commit20314fffcf5d97bab58686cdcb914637b453a166 (patch)
tree2a208d9e838558ec4688aad856fc6cc09728fcf3 /test/CodeGenCXX/vtt-layout.cpp
parent425c7ed03b5c7d4263f592416338642b6d99f3ba (diff)
Fix a bunch of VTT layout bugs, add simple tests for VTT layout.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93709 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenCXX/vtt-layout.cpp')
-rw-r--r--test/CodeGenCXX/vtt-layout.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/CodeGenCXX/vtt-layout.cpp b/test/CodeGenCXX/vtt-layout.cpp
new file mode 100644
index 0000000000..1e78c9048d
--- /dev/null
+++ b/test/CodeGenCXX/vtt-layout.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+
+namespace Test1 {
+struct A { };
+
+struct B : virtual A {
+ virtual void f();
+};
+
+void B::f() { }
+}
+
+// Test1::B should just have a single entry in its VTT, which points to the vtable.
+// CHECK: @_ZTTN5Test11BE = constant [1 x i8*] [i8* bitcast (i8** getelementptr inbounds ([4 x i8*]* @_ZTVN5Test11BE, i64 0, i64 3) to i8*)]
+
+namespace Test2 {
+ struct A { };
+
+ struct B : A { virtual void f(); };
+ struct C : virtual B { };
+
+ C c;
+}
+
+// Check that we don't add a secondary virtual pointer for Test2::A, since Test2::A doesn't have any virtual member functions or bases.
+// CHECK: @_ZTTN5Test21CE = weak_odr constant [2 x i8*] [i8* bitcast (i8** getelementptr inbounds ([5 x i8*]* @_ZTVN5Test21CE, i64 0, i64 4) to i8*), i8* bitcast (i8** getelementptr inbounds ([5 x i8*]* @_ZTVN5Test21CE, i64 0, i64 4) to i8*)] ; <[2 x i8*]*> [#uses=0]