[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / CodeGenCXX / vtable-key-function-ios.cpp
blobff2793ad51f948f3025a467a21e3e761de8cc442
1 // RUN: %clang_cc1 %s -triple=armv7-apple-darwin -emit-llvm -o - | FileCheck -check-prefixes=CHECK,CHECK-UNIX %s
2 // RUN: %clang_cc1 %s -triple=armv7-apple-darwin -emit-llvm -o - | FileCheck -check-prefix=CHECK-LATE %s
4 // RUN: %clang_cc1 %s -triple=x86_64-pc-windows-gnu -emit-llvm -o - | FileCheck -check-prefixes=CHECK,CHECK-MINGW %s
5 // RUN: %clang_cc1 %s -triple=x86_64-pc-windows-gnu -emit-llvm -o - | FileCheck -check-prefix=CHECK-LATE %s
7 // The 'a' variants ask for the vtable first.
8 // The 'b' variants ask for the vtable second.
9 // The 'c' variants ask for the vtable third.
10 // We do a separate CHECK-LATE pass because the RTTI definition gets
11 // changed after the fact, which causes reordering of the globals.
13 // These are not separated into namespaces because the way that Sema
14 // currently reports namespaces to IR-generation (i.e., en masse for
15 // the entire namespace at once) subverts the ordering that we're
16 // trying to test.
18 namespace std { class type_info; }
19 extern void use(const std::type_info &rtti);
21 /*** Test0a ******************************************************************/
23 struct Test0a {
24 Test0a();
25 virtual inline void foo();
26 virtual void bar();
29 // V-table should be defined externally.
30 Test0a::Test0a() { use(typeid(Test0a)); }
31 // CHECK: @_ZTV6Test0a = external {{(dso_local )?}}unnamed_addr constant
32 // CHECK-UNIX: @_ZTI6Test0a = external {{(dso_local )?}}constant
33 // CHECK-MINGW: @_ZTI6Test0a = linkonce_odr {{(dso_local )?}}constant
35 // This is not a key function.
36 void Test0a::foo() {}
38 /*** Test0b ******************************************************************/
40 struct Test0b {
41 Test0b();
42 virtual inline void foo();
43 virtual void bar();
46 // This is not a key function.
47 void Test0b::foo() {}
49 // V-table should be defined externally.
50 Test0b::Test0b() { use(typeid(Test0b)); }
51 // CHECK: @_ZTV6Test0b = external {{(dso_local )?}}unnamed_addr constant
52 // CHECK-UNIX: @_ZTI6Test0b = external {{(dso_local )?}}constant
53 // CHECK-MINGW: @_ZTI6Test0b = linkonce_odr {{(dso_local )?}}constant
55 /*** Test1a ******************************************************************/
57 struct Test1a {
58 Test1a();
59 virtual void foo();
60 virtual void bar();
63 // V-table needs to be defined weakly.
64 Test1a::Test1a() { use(typeid(Test1a)); }
65 // CHECK: @_ZTV6Test1a = linkonce_odr {{(dso_local )?}}unnamed_addr constant
66 // CHECK-LATE: @_ZTS6Test1a = linkonce_odr {{(dso_local )?}}constant
67 // CHECK-LATE: @_ZTI6Test1a = linkonce_odr {{(dso_local )?}}constant
69 // This defines the key function.
70 inline void Test1a::foo() {}
72 /*** Test1b ******************************************************************/
74 struct Test1b {
75 Test1b();
76 virtual void foo();
77 virtual void bar();
80 // This defines the key function.
81 inline void Test1b::foo() {}
83 // V-table should be defined weakly..
84 Test1b::Test1b() { use(typeid(Test1b)); }
85 // CHECK: @_ZTV6Test1b = linkonce_odr {{(dso_local )?}}unnamed_addr constant
86 // CHECK: @_ZTS6Test1b = linkonce_odr {{(dso_local )?}}constant
87 // CHECK: @_ZTI6Test1b = linkonce_odr {{(dso_local )?}}constant
89 /*** Test2a ******************************************************************/
91 struct Test2a {
92 Test2a();
93 virtual void foo();
94 virtual void bar();
97 // V-table should be defined with weak linkage.
98 Test2a::Test2a() { use(typeid(Test2a)); }
99 // CHECK: @_ZTV6Test2a = linkonce_odr {{(dso_local )?}}unnamed_addr constant
100 // CHECK-LATE: @_ZTS6Test2a = linkonce_odr {{(dso_local )?}}constant
101 // CHECK-LATE: @_ZTI6Test2a = linkonce_odr {{(dso_local )?}}constant
103 void Test2a::bar() {}
104 inline void Test2a::foo() {}
106 /*** Test2b ******************************************************************/
108 struct Test2b {
109 Test2b();
110 virtual void foo();
111 virtual void bar();
114 void Test2b::bar() {}
116 // V-table should be defined with weak linkage.
117 Test2b::Test2b() { use(typeid(Test2b)); }
118 // CHECK: @_ZTV6Test2b = linkonce_odr {{(dso_local )?}}unnamed_addr constant
119 // CHECK-LATE: @_ZTS6Test2b = linkonce_odr {{(dso_local )?}}constant
120 // CHECK-LATE: @_ZTI6Test2b = linkonce_odr {{(dso_local )?}}constant
122 inline void Test2b::foo() {}
124 /*** Test2c ******************************************************************/
126 struct Test2c {
127 Test2c();
128 virtual void foo();
129 virtual void bar();
132 void Test2c::bar() {}
133 inline void Test2c::foo() {}
135 // V-table should be defined with weak linkage.
136 Test2c::Test2c() { use(typeid(Test2c)); }
137 // CHECK: @_ZTV6Test2c = linkonce_odr {{(dso_local )?}}unnamed_addr constant
138 // CHECK: @_ZTS6Test2c = linkonce_odr {{(dso_local )?}}constant
139 // CHECK: @_ZTI6Test2c = linkonce_odr {{(dso_local )?}}constant
141 /*** Test3a ******************************************************************/
143 struct Test3a {
144 Test3a();
145 virtual void foo();
146 virtual void bar();
149 // V-table should be defined with weak linkage.
150 Test3a::Test3a() { use(typeid(Test3a)); }
151 // CHECK: @_ZTV6Test3a = linkonce_odr {{(dso_local )?}}unnamed_addr constant
152 // CHECK-LATE: @_ZTS6Test3a = linkonce_odr {{(dso_local )?}}constant
153 // CHECK-LATE: @_ZTI6Test3a = linkonce_odr {{(dso_local )?}}constant
155 // This defines the key function.
156 inline void Test3a::bar() {}
157 inline void Test3a::foo() {}
159 /*** Test3b ******************************************************************/
161 struct Test3b {
162 Test3b();
163 virtual void foo();
164 virtual void bar();
167 inline void Test3b::bar() {}
169 // V-table should be defined with weak linkage.
170 Test3b::Test3b() { use(typeid(Test3b)); }
171 // CHECK: @_ZTV6Test3b = linkonce_odr {{(dso_local )?}}unnamed_addr constant
172 // CHECK-LATE: @_ZTS6Test3b = linkonce_odr {{(dso_local )?}}constant
173 // CHECK-LATE: @_ZTI6Test3b = linkonce_odr {{(dso_local )?}}constant
175 // This defines the key function.
176 inline void Test3b::foo() {}
178 /*** Test3c ******************************************************************/
180 struct Test3c {
181 Test3c();
182 virtual void foo();
183 virtual void bar();
186 // This defines the key function.
187 inline void Test3c::bar() {}
188 inline void Test3c::foo() {}
190 // V-table should be defined with weak linkage.
191 Test3c::Test3c() { use(typeid(Test3c)); }
192 // CHECK: @_ZTV6Test3c = linkonce_odr {{(dso_local )?}}unnamed_addr constant
193 // CHECK: @_ZTS6Test3c = linkonce_odr {{(dso_local )?}}constant
194 // CHECK: @_ZTI6Test3c = linkonce_odr {{(dso_local )?}}constant