1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -std=c++11 -emit-llvm -o - | FileCheck %s
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc // Test1::B should just have a single entry in its VTT, which points to the vtable.
4*f4a2713aSLionel Sambuc namespace Test1 {
5*f4a2713aSLionel Sambuc struct A { };
6*f4a2713aSLionel Sambuc 
7*f4a2713aSLionel Sambuc struct B : virtual A {
8*f4a2713aSLionel Sambuc   virtual void f();
9*f4a2713aSLionel Sambuc };
10*f4a2713aSLionel Sambuc 
f()11*f4a2713aSLionel Sambuc void B::f() { }
12*f4a2713aSLionel Sambuc }
13*f4a2713aSLionel Sambuc 
14*f4a2713aSLionel Sambuc // 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.
15*f4a2713aSLionel Sambuc namespace Test2 {
16*f4a2713aSLionel Sambuc   struct A { };
17*f4a2713aSLionel Sambuc 
18*f4a2713aSLionel Sambuc   struct B : A { virtual void f(); };
19*f4a2713aSLionel Sambuc   struct C : virtual B { };
20*f4a2713aSLionel Sambuc 
21*f4a2713aSLionel Sambuc   C c;
22*f4a2713aSLionel Sambuc }
23*f4a2713aSLionel Sambuc 
24*f4a2713aSLionel Sambuc // This is the sample from the C++ Itanium ABI, p2.6.2.
25*f4a2713aSLionel Sambuc namespace Test3 {
26*f4a2713aSLionel Sambuc   class A1 { int i; };
27*f4a2713aSLionel Sambuc   class A2 { int i; virtual void f(); };
28*f4a2713aSLionel Sambuc   class V1 : public A1, public A2 { int i; };
29*f4a2713aSLionel Sambuc   class B1 { int i; };
30*f4a2713aSLionel Sambuc   class B2 { int i; };
31*f4a2713aSLionel Sambuc   class V2 : public B1, public B2, public virtual V1 { int i; };
32*f4a2713aSLionel Sambuc   class V3 {virtual void g(); };
33*f4a2713aSLionel Sambuc   class C1 : public virtual V1 { int i; };
34*f4a2713aSLionel Sambuc   class C2 : public virtual V3, virtual V2 { int i; };
35*f4a2713aSLionel Sambuc   class X1 { int i; };
36*f4a2713aSLionel Sambuc   class C3 : public X1 { int i; };
37*f4a2713aSLionel Sambuc   class D : public C1, public C2, public C3 { int i;  };
38*f4a2713aSLionel Sambuc 
39*f4a2713aSLionel Sambuc   D d;
40*f4a2713aSLionel Sambuc }
41*f4a2713aSLionel Sambuc 
42*f4a2713aSLionel Sambuc // This is the sample from the C++ Itanium ABI, p2.6.2, with the change suggested
43*f4a2713aSLionel Sambuc // (making A2 a virtual base of V1)
44*f4a2713aSLionel Sambuc namespace Test4 {
45*f4a2713aSLionel Sambuc   class A1 { int i; };
46*f4a2713aSLionel Sambuc   class A2 { int i; virtual void f(); };
47*f4a2713aSLionel Sambuc   class V1 : public A1, public virtual A2 { int i; };
48*f4a2713aSLionel Sambuc   class B1 { int i; };
49*f4a2713aSLionel Sambuc   class B2 { int i; };
50*f4a2713aSLionel Sambuc   class V2 : public B1, public B2, public virtual V1 { int i; };
51*f4a2713aSLionel Sambuc   class V3 {virtual void g(); };
52*f4a2713aSLionel Sambuc   class C1 : public virtual V1 { int i; };
53*f4a2713aSLionel Sambuc   class C2 : public virtual V3, virtual V2 { int i; };
54*f4a2713aSLionel Sambuc   class X1 { int i; };
55*f4a2713aSLionel Sambuc   class C3 : public X1 { int i; };
56*f4a2713aSLionel Sambuc   class D : public C1, public C2, public C3 { int i;  };
57*f4a2713aSLionel Sambuc 
58*f4a2713aSLionel Sambuc   D d;
59*f4a2713aSLionel Sambuc }
60*f4a2713aSLionel Sambuc 
61*f4a2713aSLionel Sambuc namespace Test5 {
62*f4a2713aSLionel Sambuc   struct A {
63*f4a2713aSLionel Sambuc     virtual void f() = 0;
64*f4a2713aSLionel Sambuc     virtual void anchor();
65*f4a2713aSLionel Sambuc   };
66*f4a2713aSLionel Sambuc 
anchor()67*f4a2713aSLionel Sambuc   void A::anchor() {
68*f4a2713aSLionel Sambuc   }
69*f4a2713aSLionel Sambuc }
70*f4a2713aSLionel Sambuc 
71*f4a2713aSLionel Sambuc namespace Test6 {
72*f4a2713aSLionel Sambuc   struct A {
73*f4a2713aSLionel Sambuc     virtual void f() = delete;
74*f4a2713aSLionel Sambuc     virtual void anchor();
75*f4a2713aSLionel Sambuc   };
76*f4a2713aSLionel Sambuc 
anchor()77*f4a2713aSLionel Sambuc   void A::anchor() {
78*f4a2713aSLionel Sambuc   }
79*f4a2713aSLionel Sambuc }
80*f4a2713aSLionel Sambuc 
81*f4a2713aSLionel Sambuc // CHECK: @_ZTTN5Test11BE = unnamed_addr constant [1 x i8*] [i8* bitcast (i8** getelementptr inbounds ([4 x i8*]* @_ZTVN5Test11BE, i64 0, i64 3) to i8*)]
82*f4a2713aSLionel Sambuc // CHECK: @_ZTVN5Test51AE = unnamed_addr constant [4 x i8*] [i8* null, i8* bitcast ({ i8*, i8* }* @_ZTIN5Test51AE to i8*), i8* bitcast (void ()* @__cxa_pure_virtual to i8*), i8* bitcast (void (%"struct.Test5::A"*)* @_ZN5Test51A6anchorEv to i8*)]
83*f4a2713aSLionel Sambuc // CHECK: @_ZTVN5Test61AE = unnamed_addr constant [4 x i8*] [i8* null, i8* bitcast ({ i8*, i8* }* @_ZTIN5Test61AE to i8*), i8* bitcast (void ()* @__cxa_deleted_virtual to i8*), i8* bitcast (void (%"struct.Test6::A"*)* @_ZN5Test61A6anchorEv to i8*)]
84*f4a2713aSLionel Sambuc // CHECK: @_ZTTN5Test41DE = linkonce_odr unnamed_addr constant [19 x i8*] [i8* bitcast (i8** getelementptr inbounds ([25 x i8*]* @_ZTVN5Test41DE, i64 0, i64 6) to i8*), i8* bitcast (i8** getelementptr inbounds ([11 x i8*]* @_ZTCN5Test41DE0_NS_2C1E, i64 0, i64 4) to i8*), i8* bitcast (i8** getelementptr inbounds ([11 x i8*]* @_ZTCN5Test41DE0_NS_2C1E, i64 0, i64 7) to i8*), i8* bitcast (i8** getelementptr inbounds ([11 x i8*]* @_ZTCN5Test41DE0_NS_2C1E, i64 0, i64 10) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*]* @_ZTCN5Test41DE16_NS_2C2E, i64 0, i64 7) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*]* @_ZTCN5Test41DE16_NS_2C2E, i64 0, i64 7) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*]* @_ZTCN5Test41DE16_NS_2C2E, i64 0, i64 12) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*]* @_ZTCN5Test41DE16_NS_2C2E, i64 0, i64 15) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*]* @_ZTCN5Test41DE16_NS_2C2E, i64 0, i64 18) to i8*), i8* bitcast (i8** getelementptr inbounds ([25 x i8*]* @_ZTVN5Test41DE, i64 0, i64 17) to i8*), i8* bitcast (i8** getelementptr inbounds ([25 x i8*]* @_ZTVN5Test41DE, i64 0, i64 20) to i8*), i8* bitcast (i8** getelementptr inbounds ([25 x i8*]* @_ZTVN5Test41DE, i64 0, i64 13) to i8*), i8* bitcast (i8** getelementptr inbounds ([25 x i8*]* @_ZTVN5Test41DE, i64 0, i64 13) to i8*), i8* bitcast (i8** getelementptr inbounds ([25 x i8*]* @_ZTVN5Test41DE, i64 1, i64 0) to i8*), i8* bitcast (i8** getelementptr inbounds ([7 x i8*]* @_ZTCN5Test41DE40_NS_2V1E, i64 0, i64 3) to i8*), i8* bitcast (i8** getelementptr inbounds ([7 x i8*]* @_ZTCN5Test41DE40_NS_2V1E, i64 0, i64 6) to i8*), i8* bitcast (i8** getelementptr inbounds ([11 x i8*]* @_ZTCN5Test41DE72_NS_2V2E, i64 0, i64 4) to i8*), i8* bitcast (i8** getelementptr inbounds ([11 x i8*]* @_ZTCN5Test41DE72_NS_2V2E, i64 0, i64 7) to i8*), i8* bitcast (i8** getelementptr inbounds ([11 x i8*]* @_ZTCN5Test41DE72_NS_2V2E, i64 0, i64 10) to i8*)]
85*f4a2713aSLionel Sambuc // CHECK: @_ZTTN5Test31DE = linkonce_odr unnamed_addr constant [13 x i8*] [i8* bitcast (i8** getelementptr inbounds ([19 x i8*]* @_ZTVN5Test31DE, i64 0, i64 5) to i8*), i8* bitcast (i8** getelementptr inbounds ([7 x i8*]* @_ZTCN5Test31DE0_NS_2C1E, i64 0, i64 3) to i8*), i8* bitcast (i8** getelementptr inbounds ([7 x i8*]* @_ZTCN5Test31DE0_NS_2C1E, i64 0, i64 6) to i8*), i8* bitcast (i8** getelementptr inbounds ([14 x i8*]* @_ZTCN5Test31DE16_NS_2C2E, i64 0, i64 6) to i8*), i8* bitcast (i8** getelementptr inbounds ([14 x i8*]* @_ZTCN5Test31DE16_NS_2C2E, i64 0, i64 6) to i8*), i8* bitcast (i8** getelementptr inbounds ([14 x i8*]* @_ZTCN5Test31DE16_NS_2C2E, i64 0, i64 10) to i8*), i8* bitcast (i8** getelementptr inbounds ([14 x i8*]* @_ZTCN5Test31DE16_NS_2C2E, i64 0, i64 13) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*]* @_ZTVN5Test31DE, i64 0, i64 15) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*]* @_ZTVN5Test31DE, i64 0, i64 11) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*]* @_ZTVN5Test31DE, i64 0, i64 11) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*]* @_ZTVN5Test31DE, i64 1, i64 0) to i8*), i8* bitcast (i8** getelementptr inbounds ([7 x i8*]* @_ZTCN5Test31DE64_NS_2V2E, i64 0, i64 3) to i8*), i8* bitcast (i8** getelementptr inbounds ([7 x i8*]* @_ZTCN5Test31DE64_NS_2V2E, i64 0, i64 6) to i8*)]
86*f4a2713aSLionel Sambuc // CHECK: @_ZTTN5Test21CE = linkonce_odr unnamed_addr 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*)]
87