[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / CodeGenCXX / vtable-key-function-arm.cpp
bloba054fd87c8ea73f1578e98752dd64e1a7933916b
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
13 // trying to test.
15 namespace std { class type_info; }
16 extern void use(const std::type_info &rtti);
18 /*** Test0a ******************************************************************/
20 struct Test0a {
21 Test0a();
22 virtual inline void foo();
23 virtual void bar();
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.
32 void Test0a::foo() {}
34 /*** Test0b ******************************************************************/
36 struct Test0b {
37 Test0b();
38 virtual inline void foo();
39 virtual void bar();
42 // This is still not a key function.
43 void Test0b::foo() {}
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 ******************************************************************/
52 struct Test1a {
53 Test1a();
54 virtual void foo();
55 virtual void bar();
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 ******************************************************************/
68 struct Test1b {
69 Test1b();
70 virtual void foo();
71 virtual void bar();
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 ******************************************************************/
84 struct Test2a {
85 Test2a();
86 virtual void foo();
87 virtual void bar();
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.
97 void Test2a::bar() {}
98 inline void Test2a::foo() {}
100 /*** Test2b ******************************************************************/
102 struct Test2b {
103 Test2b();
104 virtual void foo();
105 virtual void bar();
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 ******************************************************************/
121 struct Test2c {
122 Test2c();
123 virtual void foo();
124 virtual void bar();
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 ******************************************************************/
139 struct Test3a {
140 Test3a();
141 virtual void foo();
142 virtual void bar();
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 ******************************************************************/
157 struct Test3b {
158 Test3b();
159 virtual void foo();
160 virtual void bar();
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 ******************************************************************/
176 struct Test3c {
177 Test3c();
178 virtual void foo();
179 virtual void bar();
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 {
195 Test4a();
196 virtual void foo();
197 virtual void bar();
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 {
213 Test4b();
214 virtual void foo();
215 virtual void bar();
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 {
232 Test4c();
233 virtual void foo();
234 virtual void bar();
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 {
250 Test5a();
251 virtual void foo();
252 virtual void bar();
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 {
271 Test5b();
272 virtual void foo();
273 virtual void bar();
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 {
292 Test5c();
293 virtual void foo();
294 virtual void bar();
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