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 3 4 // The 'a' variants ask for the v-table first. 5 // The 'b' variants ask for the v-table second. 6 // The 'c' variants ask for the v-table third. 7 // We do a separate CHECK-LATE pass because the RTTI defintion gets 8 // changed after the fact, which causes reordering of the globals. 9 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. 14 15 namespace std { class type_info; } 16 extern void use(const std::type_info &rtti); 17 18 /*** Test0a ******************************************************************/ 19 20 struct Test0a { 21 Test0a(); 22 virtual inline void foo(); 23 virtual void bar(); 24 }; 25 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 30 31 // This is still not a key function. 32 void Test0a::foo() {} 33 34 /*** Test0b ******************************************************************/ 35 36 struct Test0b { 37 Test0b(); 38 virtual inline void foo(); 39 virtual void bar(); 40 }; 41 42 // This is still not a key function. 43 void Test0b::foo() {} 44 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 49 50 /*** Test1a ******************************************************************/ 51 52 struct Test1a { 53 Test1a(); 54 virtual void foo(); 55 virtual void bar(); 56 }; 57 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 62 63 // 'bar' becomes the key function when 'foo' is defined inline. 64 inline void Test1a::foo() {} 65 66 /*** Test1b ******************************************************************/ 67 68 struct Test1b { 69 Test1b(); 70 virtual void foo(); 71 virtual void bar(); 72 }; 73 74 // 'bar' becomes the key function when 'foo' is defined inline. 75 inline void Test1b::foo() {} 76 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 81 82 /*** Test2a ******************************************************************/ 83 84 struct Test2a { 85 Test2a(); 86 virtual void foo(); 87 virtual void bar(); 88 }; 89 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 = unnamed_addr constant 95 96 // 'bar' becomes the key function when 'foo' is defined inline. 97 void Test2a::bar() {} 98 inline void Test2a::foo() {} 99 100 /*** Test2b ******************************************************************/ 101 102 struct Test2b { 103 Test2b(); 104 virtual void foo(); 105 virtual void bar(); 106 }; 107 108 // 'bar' becomes the key function when 'foo' is defined inline. 109 void Test2b::bar() {} 110 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 = unnamed_addr constant 116 117 inline void Test2b::foo() {} 118 119 /*** Test2c ******************************************************************/ 120 121 struct Test2c { 122 Test2c(); 123 virtual void foo(); 124 virtual void bar(); 125 }; 126 127 // 'bar' becomes the key function when 'foo' is defined inline. 128 void Test2c::bar() {} 129 inline void Test2c::foo() {} 130 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 = unnamed_addr constant 136 137 /*** Test3a ******************************************************************/ 138 139 struct Test3a { 140 Test3a(); 141 virtual void foo(); 142 virtual void bar(); 143 }; 144 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 unnamed_addr constant 150 151 // There ceases to be a key function after these declarations. 152 inline void Test3a::bar() {} 153 inline void Test3a::foo() {} 154 155 /*** Test3b ******************************************************************/ 156 157 struct Test3b { 158 Test3b(); 159 virtual void foo(); 160 virtual void bar(); 161 }; 162 163 // There ceases to be a key function after these declarations. 164 inline void Test3b::bar() {} 165 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 unnamed_addr constant 171 172 inline void Test3b::foo() {} 173 174 /*** Test3c ******************************************************************/ 175 176 struct Test3c { 177 Test3c(); 178 virtual void foo(); 179 virtual void bar(); 180 }; 181 182 // There ceases to be a key function after these declarations. 183 inline void Test3c::bar() {} 184 inline void Test3c::foo() {} 185 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 unnamed_addr constant 191 192 /*** Test4a ******************************************************************/ 193 194 template <class T> struct Test4a { 195 Test4a(); 196 virtual void foo(); 197 virtual void bar(); 198 }; 199 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 unnamed_addr constant 205 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() {} 209 210 /*** Test4b ******************************************************************/ 211 212 template <class T> struct Test4b { 213 Test4b(); 214 virtual void foo(); 215 virtual void bar(); 216 }; 217 218 // There ceases to be a key function after these declarations. 219 template <> inline void Test4b<int>::bar() {} 220 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 unnamed_addr constant 226 227 template <> inline void Test4b<int>::foo() {} 228 229 /*** Test4c ******************************************************************/ 230 231 template <class T> struct Test4c { 232 Test4c(); 233 virtual void foo(); 234 virtual void bar(); 235 }; 236 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() {} 240 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 unnamed_addr constant 246 247 /*** Test5a ******************************************************************/ 248 249 template <class T> struct Test5a { 250 Test5a(); 251 virtual void foo(); 252 virtual void bar(); 253 }; 254 255 template <> inline void Test5a<int>::bar(); 256 template <> inline void Test5a<int>::foo(); 257 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 unnamed_addr constant 263 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() {} 267 268 /*** Test5b ******************************************************************/ 269 270 template <class T> struct Test5b { 271 Test5b(); 272 virtual void foo(); 273 virtual void bar(); 274 }; 275 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() {} 279 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 unnamed_addr constant 285 286 template <> inline void Test5a<int>::foo(); 287 template <> inline void Test5b<int>::foo() {} 288 289 /*** Test5c ******************************************************************/ 290 291 template <class T> struct Test5c { 292 Test5c(); 293 virtual void foo(); 294 virtual void bar(); 295 }; 296 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() {} 302 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 unnamed_addr constant 308