1 // RUN: %clang_cc1 %s -triple=armv7-unknown-unknown -emit-llvm -o - | FileCheck %s
2 // RUN: %clang_cc1 %s -triple=armv7-unknown-unknown -emit-llvm -o - | FileCheck -check-prefix=CHECK-LATE %s
4 // The 'a' variants ask for the vtable first.
5 // The 'b' variants ask for the vtable second.
6 // The 'c' variants ask for the vtable third.
7 // We do a separate CHECK-LATE pass because the RTTI definition gets
8 // changed after the fact, which causes reordering of the globals.
10 // These are not separated into namespaces because the way that Sema
11 // currently reports namespaces to IR-generation (i.e., en masse for
12 // the entire namespace at once) subverts the ordering that we're
15 namespace std
{ class type_info
; }
16 extern void use(const std::type_info
&rtti
);
18 /*** Test0a ******************************************************************/
22 virtual inline void foo();
26 // V-table should be defined externally.
27 Test0a::Test0a() { use(typeid(Test0a
)); }
28 // CHECK: @_ZTV6Test0a = external unnamed_addr constant
29 // CHECK: @_ZTI6Test0a = external constant
31 // This is still not a key function.
34 /*** Test0b ******************************************************************/
38 virtual inline void foo();
42 // This is still not a key function.
45 // V-table should be defined externally.
46 Test0b::Test0b() { use(typeid(Test0b
)); }
47 // CHECK: @_ZTV6Test0b = external unnamed_addr constant
48 // CHECK: @_ZTI6Test0b = external constant
50 /*** Test1a ******************************************************************/
58 // V-table should be defined externally.
59 Test1a::Test1a() { use(typeid(Test1a
)); }
60 // CHECK: @_ZTV6Test1a = external unnamed_addr constant
61 // CHECK: @_ZTI6Test1a = external constant
63 // 'bar' becomes the key function when 'foo' is defined inline.
64 inline void Test1a::foo() {}
66 /*** Test1b ******************************************************************/
74 // 'bar' becomes the key function when 'foo' is defined inline.
75 inline void Test1b::foo() {}
77 // V-table should be defined externally.
78 Test1b::Test1b() { use(typeid(Test1b
)); }
79 // CHECK: @_ZTV6Test1b = external unnamed_addr constant
80 // CHECK: @_ZTI6Test1b = external constant
82 /*** Test2a ******************************************************************/
90 // V-table should be defined with strong linkage.
91 Test2a::Test2a() { use(typeid(Test2a
)); }
92 // CHECK: @_ZTV6Test2a ={{.*}} unnamed_addr constant
93 // CHECK-LATE: @_ZTS6Test2a ={{.*}} constant
94 // CHECK-LATE: @_ZTI6Test2a ={{.*}} constant
96 // 'bar' becomes the key function when 'foo' is defined inline.
98 inline void Test2a::foo() {}
100 /*** Test2b ******************************************************************/
108 // 'bar' becomes the key function when 'foo' is defined inline.
109 void Test2b::bar() {}
111 // V-table should be defined with strong linkage.
112 Test2b::Test2b() { use(typeid(Test2b
)); }
113 // CHECK: @_ZTV6Test2b ={{.*}} unnamed_addr constant
114 // CHECK-LATE: @_ZTS6Test2b ={{.*}} constant
115 // CHECK-LATE: @_ZTI6Test2b ={{.*}} constant
117 inline void Test2b::foo() {}
119 /*** Test2c ******************************************************************/
127 // 'bar' becomes the key function when 'foo' is defined inline.
128 void Test2c::bar() {}
129 inline void Test2c::foo() {}
131 // V-table should be defined with strong linkage.
132 Test2c::Test2c() { use(typeid(Test2c
)); }
133 // CHECK: @_ZTV6Test2c ={{.*}} unnamed_addr constant
134 // CHECK: @_ZTS6Test2c ={{.*}} constant
135 // CHECK: @_ZTI6Test2c ={{.*}} constant
137 /*** Test3a ******************************************************************/
145 // V-table should be defined with weak linkage.
146 Test3a::Test3a() { use(typeid(Test3a
)); }
147 // CHECK: @_ZTV6Test3a = linkonce_odr unnamed_addr constant
148 // CHECK-LATE: @_ZTS6Test3a = linkonce_odr constant
149 // CHECK-LATE: @_ZTI6Test3a = linkonce_odr constant
151 // There ceases to be a key function after these declarations.
152 inline void Test3a::bar() {}
153 inline void Test3a::foo() {}
155 /*** Test3b ******************************************************************/
163 // There ceases to be a key function after these declarations.
164 inline void Test3b::bar() {}
166 // V-table should be defined with weak linkage.
167 Test3b::Test3b() { use(typeid(Test3b
)); }
168 // CHECK: @_ZTV6Test3b = linkonce_odr unnamed_addr constant
169 // CHECK-LATE: @_ZTS6Test3b = linkonce_odr constant
170 // CHECK-LATE: @_ZTI6Test3b = linkonce_odr constant
172 inline void Test3b::foo() {}
174 /*** Test3c ******************************************************************/
182 // There ceases to be a key function after these declarations.
183 inline void Test3c::bar() {}
184 inline void Test3c::foo() {}
186 // V-table should be defined with weak linkage.
187 Test3c::Test3c() { use(typeid(Test3c
)); }
188 // CHECK: @_ZTV6Test3c = linkonce_odr unnamed_addr constant
189 // CHECK: @_ZTS6Test3c = linkonce_odr constant
190 // CHECK: @_ZTI6Test3c = linkonce_odr constant
192 /*** Test4a ******************************************************************/
194 template <class T
> struct Test4a
{
200 // V-table should be defined with weak linkage.
201 template <> Test4a
<int>::Test4a() { use(typeid(Test4a
)); }
202 // CHECK: @_ZTV6Test4aIiE = linkonce_odr unnamed_addr constant
203 // CHECK: @_ZTS6Test4aIiE = linkonce_odr constant
204 // CHECK: @_ZTI6Test4aIiE = linkonce_odr constant
206 // There ceases to be a key function after these declarations.
207 template <> inline void Test4a
<int>::bar() {}
208 template <> inline void Test4a
<int>::foo() {}
210 /*** Test4b ******************************************************************/
212 template <class T
> struct Test4b
{
218 // There ceases to be a key function after these declarations.
219 template <> inline void Test4b
<int>::bar() {}
221 // V-table should be defined with weak linkage.
222 template <> Test4b
<int>::Test4b() { use(typeid(Test4b
)); }
223 // CHECK: @_ZTV6Test4bIiE = linkonce_odr unnamed_addr constant
224 // CHECK: @_ZTS6Test4bIiE = linkonce_odr constant
225 // CHECK: @_ZTI6Test4bIiE = linkonce_odr constant
227 template <> inline void Test4b
<int>::foo() {}
229 /*** Test4c ******************************************************************/
231 template <class T
> struct Test4c
{
237 // There ceases to be a key function after these declarations.
238 template <> inline void Test4c
<int>::bar() {}
239 template <> inline void Test4c
<int>::foo() {}
241 // V-table should be defined with weak linkage.
242 template <> Test4c
<int>::Test4c() { use(typeid(Test4c
)); }
243 // CHECK: @_ZTV6Test4cIiE = linkonce_odr unnamed_addr constant
244 // CHECK: @_ZTS6Test4cIiE = linkonce_odr constant
245 // CHECK: @_ZTI6Test4cIiE = linkonce_odr constant
247 /*** Test5a ******************************************************************/
249 template <class T
> struct Test5a
{
255 template <> inline void Test5a
<int>::bar();
256 template <> inline void Test5a
<int>::foo();
258 // V-table should be defined with weak linkage.
259 template <> Test5a
<int>::Test5a() { use(typeid(Test5a
)); }
260 // CHECK: @_ZTV6Test5aIiE = linkonce_odr unnamed_addr constant
261 // CHECK: @_ZTS6Test5aIiE = linkonce_odr constant
262 // CHECK: @_ZTI6Test5aIiE = linkonce_odr constant
264 // There ceases to be a key function after these declarations.
265 template <> inline void Test5a
<int>::bar() {}
266 template <> inline void Test5a
<int>::foo() {}
268 /*** Test5b ******************************************************************/
270 template <class T
> struct Test5b
{
276 // There ceases to be a key function after these declarations.
277 template <> inline void Test5a
<int>::bar();
278 template <> inline void Test5b
<int>::bar() {}
280 // V-table should be defined with weak linkage.
281 template <> Test5b
<int>::Test5b() { use(typeid(Test5b
)); }
282 // CHECK: @_ZTV6Test5bIiE = linkonce_odr unnamed_addr constant
283 // CHECK: @_ZTS6Test5bIiE = linkonce_odr constant
284 // CHECK: @_ZTI6Test5bIiE = linkonce_odr constant
286 template <> inline void Test5a
<int>::foo();
287 template <> inline void Test5b
<int>::foo() {}
289 /*** Test5c ******************************************************************/
291 template <class T
> struct Test5c
{
297 // There ceases to be a key function after these declarations.
298 template <> inline void Test5a
<int>::bar();
299 template <> inline void Test5a
<int>::foo();
300 template <> inline void Test5c
<int>::bar() {}
301 template <> inline void Test5c
<int>::foo() {}
303 // V-table should be defined with weak linkage.
304 template <> Test5c
<int>::Test5c() { use(typeid(Test5c
)); }
305 // CHECK: @_ZTV6Test5cIiE = linkonce_odr unnamed_addr constant
306 // CHECK: @_ZTS6Test5cIiE = linkonce_odr constant
307 // CHECK: @_ZTI6Test5cIiE = linkonce_odr constant