1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fapple-kext -fno-rtti -emit-llvm -o - %s | FileCheck %s
2*f4a2713aSLionel Sambuc
3*f4a2713aSLionel Sambuc // CHECK: @_ZTV1A = unnamed_addr constant [4 x i8*] [i8* null, i8* null, i8* bitcast (i8* (%struct.A*)* @_ZNK1A3abcEv to i8*), i8* null]
4*f4a2713aSLionel Sambuc // CHECK: @_ZTV4Base = unnamed_addr constant [4 x i8*] [i8* null, i8* null, i8* bitcast (i8* (%struct.A*)* @_ZNK4Base3abcEv to i8*), i8* null]
5*f4a2713aSLionel Sambuc // CHECK: @_ZTV8Derived2 = unnamed_addr constant [5 x i8*] [i8* null, i8* null, i8* null, i8* bitcast (i8* (%struct.A*)* @_ZNK8Derived23efgEv to i8*), i8* null]
6*f4a2713aSLionel Sambuc // CHECK: @_ZTV2D2 = unnamed_addr constant [5 x i8*] [i8* null, i8* null, i8* null, i8* bitcast (i8* (%struct.A*)* @_ZNK2D23abcEv to i8*), i8* null]
7*f4a2713aSLionel Sambuc
8*f4a2713aSLionel Sambuc struct A {
9*f4a2713aSLionel Sambuc virtual const char* abc(void) const;
10*f4a2713aSLionel Sambuc };
11*f4a2713aSLionel Sambuc
abc(void)12*f4a2713aSLionel Sambuc const char* A::abc(void) const {return "A"; };
13*f4a2713aSLionel Sambuc
14*f4a2713aSLionel Sambuc struct B : virtual A {
15*f4a2713aSLionel Sambuc virtual void VF();
16*f4a2713aSLionel Sambuc };
17*f4a2713aSLionel Sambuc
VF()18*f4a2713aSLionel Sambuc void B::VF() {}
19*f4a2713aSLionel Sambuc
FUNC(B * p)20*f4a2713aSLionel Sambuc void FUNC(B* p) {
21*f4a2713aSLionel Sambuc // CHECK: [[T1:%.*]] = load i8* (%struct.A*)** getelementptr inbounds (i8* (%struct.A*)** bitcast ([4 x i8*]* @_ZTV1A to i8* (%struct.A*)**), i64 2)
22*f4a2713aSLionel Sambuc // CHECK-NEXT: [[T2:%.*]] = call i8* [[T1]]
23*f4a2713aSLionel Sambuc const char* c = p->A::abc();
24*f4a2713aSLionel Sambuc }
25*f4a2713aSLionel Sambuc
26*f4a2713aSLionel Sambuc
27*f4a2713aSLionel Sambuc // Test2
28*f4a2713aSLionel Sambuc struct Base { virtual char* abc(void) const; };
29*f4a2713aSLionel Sambuc
abc()30*f4a2713aSLionel Sambuc char* Base::abc() const { return 0; }
31*f4a2713aSLionel Sambuc
32*f4a2713aSLionel Sambuc struct Derived : public Base {
33*f4a2713aSLionel Sambuc };
34*f4a2713aSLionel Sambuc
FUNC1(Derived * p)35*f4a2713aSLionel Sambuc void FUNC1(Derived* p) {
36*f4a2713aSLionel Sambuc // CHECK: [[U1:%.*]] = load i8* (%struct.A*)** getelementptr inbounds (i8* (%struct.A*)** bitcast ([4 x i8*]* @_ZTV4Base to i8* (%struct.A*)**), i64 2)
37*f4a2713aSLionel Sambuc // CHECK-NEXT: [[U2:%.*]] = call i8* [[U1]]
38*f4a2713aSLionel Sambuc char* c = p->Base::abc();
39*f4a2713aSLionel Sambuc }
40*f4a2713aSLionel Sambuc
41*f4a2713aSLionel Sambuc
42*f4a2713aSLionel Sambuc // Test3
43*f4a2713aSLionel Sambuc struct Base2 { };
44*f4a2713aSLionel Sambuc
45*f4a2713aSLionel Sambuc struct Derived2 : virtual Base2 {
46*f4a2713aSLionel Sambuc virtual char* efg(void) const;
47*f4a2713aSLionel Sambuc };
48*f4a2713aSLionel Sambuc
efg(void)49*f4a2713aSLionel Sambuc char* Derived2::efg(void) const { return 0; }
50*f4a2713aSLionel Sambuc
FUNC2(Derived2 * p)51*f4a2713aSLionel Sambuc void FUNC2(Derived2* p) {
52*f4a2713aSLionel Sambuc // CHECK: [[V1:%.*]] = load i8* (%struct.A*)** getelementptr inbounds (i8* (%struct.A*)** bitcast ([5 x i8*]* @_ZTV8Derived2 to i8* (%struct.A*)**), i64 3)
53*f4a2713aSLionel Sambuc // CHECK-NEXT: [[V2:%.*]] = call i8* [[V1]]
54*f4a2713aSLionel Sambuc char* c = p->Derived2::efg();
55*f4a2713aSLionel Sambuc }
56*f4a2713aSLionel Sambuc
57*f4a2713aSLionel Sambuc // Test4
58*f4a2713aSLionel Sambuc struct Base3 { };
59*f4a2713aSLionel Sambuc
60*f4a2713aSLionel Sambuc struct D1 : virtual Base3 {
61*f4a2713aSLionel Sambuc };
62*f4a2713aSLionel Sambuc
63*f4a2713aSLionel Sambuc struct D2 : virtual Base3 {
64*f4a2713aSLionel Sambuc virtual char *abc(void) const;
65*f4a2713aSLionel Sambuc };
66*f4a2713aSLionel Sambuc
67*f4a2713aSLionel Sambuc struct Sub : D1, D2 {
68*f4a2713aSLionel Sambuc };
69*f4a2713aSLionel Sambuc
abc(void)70*f4a2713aSLionel Sambuc char* D2::abc(void) const { return 0; }
71*f4a2713aSLionel Sambuc
FUNC3(Sub * p)72*f4a2713aSLionel Sambuc void FUNC3(Sub* p) {
73*f4a2713aSLionel Sambuc // CHECK: [[W1:%.*]] = load i8* (%struct.A*)** getelementptr inbounds (i8* (%struct.A*)** bitcast ([5 x i8*]* @_ZTV2D2 to i8* (%struct.A*)**), i64 3)
74*f4a2713aSLionel Sambuc // CHECK-NEXT: [[W2:%.*]] = call i8* [[W1]]
75*f4a2713aSLionel Sambuc char* c = p->D2::abc();
76*f4a2713aSLionel Sambuc }
77*f4a2713aSLionel Sambuc
78