1 // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
3 // See Test9 for test description.
4 // CHECK: @_ZTTN5Test91BE = linkonce_odr unnamed_addr constant
7 // Check that we don't initialize the vtable pointer in A::~A(), since the destructor body is trivial.
13 // CHECK-LABEL: define void @_ZN5Test11AD2Ev
14 // CHECK-NOT: store i32 (...)** bitcast (i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @_ZTVN5Test11AE, i64 0, i64 2) to i32 (...)**), i32 (...)***
23 // Check that we do initialize the vtable pointer in A::~A() since the destructor body isn't trivial.
29 // CHECK-LABEL: define void @_ZN5Test21AD2Ev
30 // CHECK: store i32 (...)** bitcast (i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @_ZTVN5Test21AE, i64 0, i64 2) to i32 (...)**), i32 (...)***
39 // Check that we don't initialize the vtable pointer in A::~A(), since the destructor body is trivial
40 // and Field's destructor body is also trivial.
52 // CHECK-LABEL: define void @_ZN5Test31AD2Ev
53 // CHECK-NOT: store i32 (...)** bitcast (i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @_ZTVN5Test31AE, i64 0, i64 2) to i32 (...)**), i32 (...)***
62 // Check that we do initialize the vtable pointer in A::~A(), since Field's destructor body
78 // CHECK-LABEL: define void @_ZN5Test41AD2Ev
79 // CHECK: store i32 (...)** bitcast (i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @_ZTVN5Test41AE, i64 0, i64 2) to i32 (...)**), i32 (...)***
88 // Check that we do initialize the vtable pointer in A::~A(), since Field's destructor isn't
89 // available in this translation unit.
102 // CHECK-LABEL: define void @_ZN5Test51AD2Ev
103 // CHECK: store i32 (...)** bitcast (i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @_ZTVN5Test51AE, i64 0, i64 2) to i32 (...)**), i32 (...)***
112 // Check that we do initialize the vtable pointer in A::~A(), since Field has a member
113 // variable with a non-trivial destructor body.
115 struct NonTrivialDestructorBody {
116 ~NonTrivialDestructorBody();
120 NonTrivialDestructorBody nonTrivialDestructorBody;
130 // CHECK-LABEL: define void @_ZN5Test61AD2Ev
131 // CHECK: store i32 (...)** bitcast (i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @_ZTVN5Test61AE, i64 0, i64 2) to i32 (...)**), i32 (...)***
140 // Check that we do initialize the vtable pointer in A::~A(), since Field has a base
141 // class with a non-trivial destructor body.
143 struct NonTrivialDestructorBody {
144 ~NonTrivialDestructorBody();
147 struct Field : NonTrivialDestructorBody { };
156 // CHECK-LABEL: define void @_ZN5Test71AD2Ev
157 // CHECK: store i32 (...)** bitcast (i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @_ZTVN5Test71AE, i64 0, i64 2) to i32 (...)**), i32 (...)***
166 // Check that we do initialize the vtable pointer in A::~A(), since Field has a virtual base
167 // class with a non-trivial destructor body.
169 struct NonTrivialDestructorBody {
170 ~NonTrivialDestructorBody();
173 struct Field : virtual NonTrivialDestructorBody { };
182 // CHECK-LABEL: define void @_ZN5Test81AD2Ev
183 // CHECK: store i32 (...)** bitcast (i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @_ZTVN5Test81AE, i64 0, i64 2) to i32 (...)**), i32 (...)***
192 // Check that we emit a VTT for B, even though we don't initialize the vtable pointer in the destructor.
193 struct A { virtual ~A () { } };
194 struct B : virtual A {};
195 struct C : virtual B {