1d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// RUN: %clang_cc1 %s -triple=armv7-apple-darwin -emit-llvm -o - | FileCheck %s
2d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// RUN: %clang_cc1 %s -triple=armv7-apple-darwin -emit-llvm -o - | FileCheck -check-prefix=CHECK-LATE %s
3d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall
4d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// The 'a' variants ask for the v-table first.
5d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// The 'b' variants ask for the v-table second.
6d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// The 'c' variants ask for the v-table third.
7651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines// We do a separate CHECK-LATE pass because the RTTI definition gets
8d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// changed after the fact, which causes reordering of the globals.
9d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall
10d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// These are not separated into namespaces because the way that Sema
11d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// currently reports namespaces to IR-generation (i.e., en masse for
12d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// the entire namespace at once) subverts the ordering that we're
13d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// trying to test.
14d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall
15d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCallnamespace std { class type_info; }
16d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCallextern void use(const std::type_info &rtti);
17d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall
18d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall/*** Test0a ******************************************************************/
19d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall
20d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCallstruct Test0a {
21d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall  Test0a();
22d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall  virtual inline void foo();
23d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall  virtual void bar();
24d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall};
25d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall
26d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// V-table should be defined externally.
27d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCallTest0a::Test0a() { use(typeid(Test0a)); }
28d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// CHECK: @_ZTV6Test0a = external unnamed_addr constant
29d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// CHECK: @_ZTI6Test0a = external constant
30d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall
31d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// This is not a key function.
32d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCallvoid Test0a::foo() {}
33d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall
34d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall/*** Test0b ******************************************************************/
35d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall
36d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCallstruct Test0b {
37d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall  Test0b();
38d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall  virtual inline void foo();
39d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall  virtual void bar();
40d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall};
41d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall
42d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// This is not a key function.
43d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCallvoid Test0b::foo() {}
44d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall
45d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// V-table should be defined externally.
46d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCallTest0b::Test0b() { use(typeid(Test0b)); }
47d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// CHECK: @_ZTV6Test0b = external unnamed_addr constant
48d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// CHECK: @_ZTI6Test0b = external constant
49d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall
50d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall/*** Test1a ******************************************************************/
51d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall
52d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCallstruct Test1a {
53d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall  Test1a();
54d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall  virtual void foo();
55d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall  virtual void bar();
56d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall};
57d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall
58d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// V-table needs to be defined weakly.
59d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCallTest1a::Test1a() { use(typeid(Test1a)); }
60d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// CHECK:      @_ZTV6Test1a = linkonce_odr unnamed_addr constant
61d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// CHECK-LATE: @_ZTS6Test1a = linkonce_odr constant
62651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines// CHECK-LATE: @_ZTI6Test1a = linkonce_odr constant
63d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall
64d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// This defines the key function.
65d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCallinline void Test1a::foo() {}
66d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall
67d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall/*** Test1b ******************************************************************/
68d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall
69d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCallstruct Test1b {
70d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall  Test1b();
71d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall  virtual void foo();
72d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall  virtual void bar();
73d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall};
74d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall
75d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// This defines the key function.
76d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCallinline void Test1b::foo() {}
77d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall
78d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// V-table should be defined weakly..
79d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCallTest1b::Test1b() { use(typeid(Test1b)); }
80d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// CHECK: @_ZTV6Test1b = linkonce_odr unnamed_addr constant
81d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// CHECK: @_ZTS6Test1b = linkonce_odr constant
82651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines// CHECK: @_ZTI6Test1b = linkonce_odr constant
83d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall
84d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall/*** Test2a ******************************************************************/
85d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall
86d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCallstruct Test2a {
87d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall  Test2a();
88d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall  virtual void foo();
89d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall  virtual void bar();
90d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall};
91d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall
92d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// V-table should be defined with weak linkage.
93d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCallTest2a::Test2a() { use(typeid(Test2a)); }
94d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// CHECK:      @_ZTV6Test2a = linkonce_odr unnamed_addr constant
95d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// CHECK-LATE: @_ZTS6Test2a = linkonce_odr constant
96651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines// CHECK-LATE: @_ZTI6Test2a = linkonce_odr constant
97d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall
98d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCallvoid Test2a::bar() {}
99d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCallinline void Test2a::foo() {}
100d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall
101d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall/*** Test2b ******************************************************************/
102d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall
103d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCallstruct Test2b {
104d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall  Test2b();
105d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall  virtual void foo();
106d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall  virtual void bar();
107d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall};
108d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall
109d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCallvoid Test2b::bar() {}
110d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall
111d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// V-table should be defined with weak linkage.
112d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCallTest2b::Test2b() { use(typeid(Test2b)); }
113d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// CHECK:      @_ZTV6Test2b = linkonce_odr unnamed_addr constant
114d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// CHECK-LATE: @_ZTS6Test2b = linkonce_odr constant
115651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines// CHECK-LATE: @_ZTI6Test2b = linkonce_odr constant
116d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall
117d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCallinline void Test2b::foo() {}
118d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall
119d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall/*** Test2c ******************************************************************/
120d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall
121d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCallstruct Test2c {
122d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall  Test2c();
123d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall  virtual void foo();
124d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall  virtual void bar();
125d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall};
126d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall
127d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCallvoid Test2c::bar() {}
128d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCallinline void Test2c::foo() {}
129d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall
130d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// V-table should be defined with weak linkage.
131d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCallTest2c::Test2c() { use(typeid(Test2c)); }
132d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// CHECK: @_ZTV6Test2c = linkonce_odr unnamed_addr constant
133d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// CHECK: @_ZTS6Test2c = linkonce_odr constant
134651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines// CHECK: @_ZTI6Test2c = linkonce_odr constant
135d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall
136d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall/*** Test3a ******************************************************************/
137d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall
138d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCallstruct Test3a {
139d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall  Test3a();
140d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall  virtual void foo();
141d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall  virtual void bar();
142d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall};
143d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall
144d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// V-table should be defined with weak linkage.
145d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCallTest3a::Test3a() { use(typeid(Test3a)); }
146d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// CHECK:      @_ZTV6Test3a = linkonce_odr unnamed_addr constant
147d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// CHECK-LATE: @_ZTS6Test3a = linkonce_odr constant
148651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines// CHECK-LATE: @_ZTI6Test3a = linkonce_odr constant
149d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall
150d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// This defines the key function.
151d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCallinline void Test3a::bar() {}
152d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCallinline void Test3a::foo() {}
153d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall
154d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall/*** Test3b ******************************************************************/
155d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall
156d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCallstruct Test3b {
157d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall  Test3b();
158d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall  virtual void foo();
159d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall  virtual void bar();
160d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall};
161d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall
162d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCallinline void Test3b::bar() {}
163d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall
164d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// V-table should be defined with weak linkage.
165d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCallTest3b::Test3b() { use(typeid(Test3b)); }
166d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// CHECK:      @_ZTV6Test3b = linkonce_odr unnamed_addr constant
167d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// CHECK-LATE: @_ZTS6Test3b = linkonce_odr constant
168651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines// CHECK-LATE: @_ZTI6Test3b = linkonce_odr constant
169d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall
170d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// This defines the key function.
171d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCallinline void Test3b::foo() {}
172d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall
173d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall/*** Test3c ******************************************************************/
174d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall
175d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCallstruct Test3c {
176d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall  Test3c();
177d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall  virtual void foo();
178d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall  virtual void bar();
179d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall};
180d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall
181d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// This defines the key function.
182d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCallinline void Test3c::bar() {}
183d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCallinline void Test3c::foo() {}
184d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall
185d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// V-table should be defined with weak linkage.
186d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCallTest3c::Test3c() { use(typeid(Test3c)); }
187d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// CHECK: @_ZTV6Test3c = linkonce_odr unnamed_addr constant
188d5617eeafc93209a26b9f88276c88cf997c3a0a7John McCall// CHECK: @_ZTS6Test3c = linkonce_odr constant
189651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines// CHECK: @_ZTI6Test3c = linkonce_odr constant
190