xref: /llvm-project/clang/test/CodeGenCXX/vtt-layout.cpp (revision 1af3df854f31e33f550149e576c819d94dc74f7b)
1 // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
2 
3 namespace Test1 {
4 struct A { };
5 
6 struct B : virtual A {
7   virtual void f();
8 };
9 
10 void B::f() { }
11 }
12 
13 // Test1::B should just have a single entry in its VTT, which points to the vtable.
14 // CHECK: @_ZTTN5Test11BE = constant [1 x i8*] [i8* bitcast (i8** getelementptr inbounds ([4 x i8*]* @_ZTVN5Test11BE, i64 0, i64 3) to i8*)]
15 
16 namespace Test2 {
17   struct A { };
18 
19   struct B : A { virtual void f(); };
20   struct C : virtual B { };
21 
22   C c;
23 }
24 
25 // 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.
26 // 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]
27