xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenCXX/vtable-pointer-initialization.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
2f4a2713aSLionel Sambuc 
3f4a2713aSLionel Sambuc struct Field {
4f4a2713aSLionel Sambuc   Field();
5f4a2713aSLionel Sambuc   ~Field();
6f4a2713aSLionel Sambuc };
7f4a2713aSLionel Sambuc 
8f4a2713aSLionel Sambuc struct Base {
9f4a2713aSLionel Sambuc   Base();
10f4a2713aSLionel Sambuc   ~Base();
11f4a2713aSLionel Sambuc };
12f4a2713aSLionel Sambuc 
13f4a2713aSLionel Sambuc struct A : Base {
14f4a2713aSLionel Sambuc   A();
15f4a2713aSLionel Sambuc   ~A();
16f4a2713aSLionel Sambuc 
17f4a2713aSLionel Sambuc   virtual void f();
18f4a2713aSLionel Sambuc 
19f4a2713aSLionel Sambuc   Field field;
20f4a2713aSLionel Sambuc };
21f4a2713aSLionel Sambuc 
22f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_ZN1AC2Ev(%struct.A* %this) unnamed_addr
23f4a2713aSLionel Sambuc // CHECK: call void @_ZN4BaseC2Ev(
24*0a6a1f1dSLionel Sambuc // CHECK: store i32 (...)** bitcast (i8** getelementptr inbounds ([3 x i8*]* @_ZTV1A, i64 0, i64 2) to i32 (...)**)
25f4a2713aSLionel Sambuc // CHECK: call void @_ZN5FieldC1Ev(
26f4a2713aSLionel Sambuc // CHECK: ret void
A()27f4a2713aSLionel Sambuc A::A() { }
28f4a2713aSLionel Sambuc 
29f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_ZN1AD2Ev(%struct.A* %this) unnamed_addr
30*0a6a1f1dSLionel Sambuc // CHECK: store i32 (...)** bitcast (i8** getelementptr inbounds ([3 x i8*]* @_ZTV1A, i64 0, i64 2) to i32 (...)**)
31f4a2713aSLionel Sambuc // CHECK: call void @_ZN5FieldD1Ev(
32f4a2713aSLionel Sambuc // CHECK: call void @_ZN4BaseD2Ev(
33f4a2713aSLionel Sambuc // CHECK: ret void
~A()34f4a2713aSLionel Sambuc A::~A() { }
35f4a2713aSLionel Sambuc 
36f4a2713aSLionel Sambuc struct B : Base {
37f4a2713aSLionel Sambuc   virtual void f();
38f4a2713aSLionel Sambuc 
39f4a2713aSLionel Sambuc   Field field;
40f4a2713aSLionel Sambuc };
41f4a2713aSLionel Sambuc 
f()42f4a2713aSLionel Sambuc void f() { B b; }
43f4a2713aSLionel Sambuc 
44f4a2713aSLionel Sambuc // CHECK-LABEL: define linkonce_odr void @_ZN1BC1Ev(%struct.B* %this) unnamed_addr
45f4a2713aSLionel Sambuc // CHECK: call void @_ZN1BC2Ev(
46f4a2713aSLionel Sambuc 
47f4a2713aSLionel Sambuc // CHECK-LABEL: define linkonce_odr void @_ZN1BD1Ev(%struct.B* %this) unnamed_addr
48*0a6a1f1dSLionel Sambuc // CHECK: store i32 (...)** bitcast (i8** getelementptr inbounds ([3 x i8*]* @_ZTV1B, i64 0, i64 2) to i32 (...)**)
49f4a2713aSLionel Sambuc // CHECK: call void @_ZN5FieldD1Ev(
50f4a2713aSLionel Sambuc // CHECK: call void @_ZN4BaseD2Ev(
51f4a2713aSLionel Sambuc // CHECK: ret void
52f4a2713aSLionel Sambuc 
53f4a2713aSLionel Sambuc // CHECK-LABEL: define linkonce_odr void @_ZN1BC2Ev(%struct.B* %this) unnamed_addr
54f4a2713aSLionel Sambuc // CHECK: call void @_ZN4BaseC2Ev(
55*0a6a1f1dSLionel Sambuc // CHECK: store i32 (...)** bitcast (i8** getelementptr inbounds ([3 x i8*]* @_ZTV1B, i64 0, i64 2) to i32 (...)**)
56f4a2713aSLionel Sambuc // CHECK: call void @_ZN5FieldC1Ev
57f4a2713aSLionel Sambuc // CHECK: ret void
58