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