• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 
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
6 
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.
12 
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.
17 
18 namespace std { class type_info; }
19 extern void use(const std::type_info &rtti);
20 
21 /*** Test0a ******************************************************************/
22 
23 struct Test0a {
24   Test0a();
25   virtual inline void foo();
26   virtual void bar();
27 };
28 
29 // V-table should be defined externally.
Test0a()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
34 
35 // This is not a key function.
foo()36 void Test0a::foo() {}
37 
38 /*** Test0b ******************************************************************/
39 
40 struct Test0b {
41   Test0b();
42   virtual inline void foo();
43   virtual void bar();
44 };
45 
46 // This is not a key function.
foo()47 void Test0b::foo() {}
48 
49 // V-table should be defined externally.
Test0b()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
54 
55 /*** Test1a ******************************************************************/
56 
57 struct Test1a {
58   Test1a();
59   virtual void foo();
60   virtual void bar();
61 };
62 
63 // V-table needs to be defined weakly.
Test1a()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
68 
69 // This defines the key function.
foo()70 inline void Test1a::foo() {}
71 
72 /*** Test1b ******************************************************************/
73 
74 struct Test1b {
75   Test1b();
76   virtual void foo();
77   virtual void bar();
78 };
79 
80 // This defines the key function.
foo()81 inline void Test1b::foo() {}
82 
83 // V-table should be defined weakly..
Test1b()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
88 
89 /*** Test2a ******************************************************************/
90 
91 struct Test2a {
92   Test2a();
93   virtual void foo();
94   virtual void bar();
95 };
96 
97 // V-table should be defined with weak linkage.
Test2a()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
102 
bar()103 void Test2a::bar() {}
foo()104 inline void Test2a::foo() {}
105 
106 /*** Test2b ******************************************************************/
107 
108 struct Test2b {
109   Test2b();
110   virtual void foo();
111   virtual void bar();
112 };
113 
bar()114 void Test2b::bar() {}
115 
116 // V-table should be defined with weak linkage.
Test2b()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
121 
foo()122 inline void Test2b::foo() {}
123 
124 /*** Test2c ******************************************************************/
125 
126 struct Test2c {
127   Test2c();
128   virtual void foo();
129   virtual void bar();
130 };
131 
bar()132 void Test2c::bar() {}
foo()133 inline void Test2c::foo() {}
134 
135 // V-table should be defined with weak linkage.
Test2c()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
140 
141 /*** Test3a ******************************************************************/
142 
143 struct Test3a {
144   Test3a();
145   virtual void foo();
146   virtual void bar();
147 };
148 
149 // V-table should be defined with weak linkage.
Test3a()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
154 
155 // This defines the key function.
bar()156 inline void Test3a::bar() {}
foo()157 inline void Test3a::foo() {}
158 
159 /*** Test3b ******************************************************************/
160 
161 struct Test3b {
162   Test3b();
163   virtual void foo();
164   virtual void bar();
165 };
166 
bar()167 inline void Test3b::bar() {}
168 
169 // V-table should be defined with weak linkage.
Test3b()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
174 
175 // This defines the key function.
foo()176 inline void Test3b::foo() {}
177 
178 /*** Test3c ******************************************************************/
179 
180 struct Test3c {
181   Test3c();
182   virtual void foo();
183   virtual void bar();
184 };
185 
186 // This defines the key function.
bar()187 inline void Test3c::bar() {}
foo()188 inline void Test3c::foo() {}
189 
190 // V-table should be defined with weak linkage.
Test3c()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
195