brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.4 KiB · b11d0a6 Raw
197 lines · cpp
1// RUN: %clang_cc1 %s -triple=armv7-apple-darwin -emit-llvm -o - | FileCheck -check-prefixes=CHECK,CHECK-UNIX %s2// RUN: %clang_cc1 %s -triple=armv7-apple-darwin -emit-llvm -o - | FileCheck -check-prefix=CHECK-LATE %s3 4// RUN: %clang_cc1 %s -triple=x86_64-pc-windows-gnu -emit-llvm -o - | FileCheck -check-prefixes=CHECK,CHECK-MINGW %s5// RUN: %clang_cc1 %s -triple=x86_64-pc-windows-gnu -emit-llvm -o - | FileCheck -check-prefix=CHECK-LATE %s6// RUN: %clang_cc1 %s -triple=x86_64-pc-cygwin      -emit-llvm -o - | FileCheck -check-prefixes=CHECK,CHECK-MINGW %s7// RUN: %clang_cc1 %s -triple=x86_64-pc-cygwin      -emit-llvm -o - | FileCheck -check-prefix=CHECK-LATE %s8 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 gets13// changed after the fact, which causes reordering of the globals.14 15// These are not separated into namespaces because the way that Sema16// currently reports namespaces to IR-generation (i.e., en masse for17// the entire namespace at once) subverts the ordering that we're18// trying to test.19 20namespace std { class type_info; }21extern void use(const std::type_info &rtti);22 23/*** Test0a ******************************************************************/24 25struct Test0a {26  Test0a();27  virtual inline void foo();28  virtual void bar();29};30 31// V-table should be defined externally.32Test0a::Test0a() { use(typeid(Test0a)); }33// CHECK: @_ZTV6Test0a = external {{(dso_local )?}}unnamed_addr constant 34// CHECK-UNIX: @_ZTI6Test0a = external {{(dso_local )?}}constant35// CHECK-MINGW: @_ZTI6Test0a = linkonce_odr {{(dso_local )?}}constant36 37// This is not a key function.38void Test0a::foo() {}39 40/*** Test0b ******************************************************************/41 42struct Test0b {43  Test0b();44  virtual inline void foo();45  virtual void bar();46};47 48// This is not a key function.49void Test0b::foo() {}50 51// V-table should be defined externally.52Test0b::Test0b() { use(typeid(Test0b)); }53// CHECK: @_ZTV6Test0b = external {{(dso_local )?}}unnamed_addr constant 54// CHECK-UNIX: @_ZTI6Test0b = external {{(dso_local )?}}constant55// CHECK-MINGW: @_ZTI6Test0b = linkonce_odr {{(dso_local )?}}constant56 57/*** Test1a ******************************************************************/58 59struct Test1a {60  Test1a();61  virtual void foo();62  virtual void bar();63};64 65// V-table needs to be defined weakly.66Test1a::Test1a() { use(typeid(Test1a)); }67// CHECK:      @_ZTV6Test1a = linkonce_odr {{(dso_local )?}}unnamed_addr constant 68// CHECK-LATE: @_ZTI6Test1a = linkonce_odr {{(dso_local )?}}constant69// CHECK-LATE: @_ZTS6Test1a = linkonce_odr {{(dso_local )?}}constant70 71// This defines the key function.72inline void Test1a::foo() {}73 74/*** Test1b ******************************************************************/75 76struct Test1b {77  Test1b();78  virtual void foo();79  virtual void bar();80};81 82// This defines the key function.83inline void Test1b::foo() {}84 85// V-table should be defined weakly..86Test1b::Test1b() { use(typeid(Test1b)); }87// CHECK: @_ZTV6Test1b = linkonce_odr {{(dso_local )?}}unnamed_addr constant 88// CHECK: @_ZTI6Test1b = linkonce_odr {{(dso_local )?}}constant89// CHECK: @_ZTS6Test1b = linkonce_odr {{(dso_local )?}}constant90 91/*** Test2a ******************************************************************/92 93struct Test2a {94  Test2a();95  virtual void foo();96  virtual void bar();97};98 99// V-table should be defined with weak linkage.100Test2a::Test2a() { use(typeid(Test2a)); }101// CHECK:      @_ZTV6Test2a = linkonce_odr {{(dso_local )?}}unnamed_addr constant102// CHECK-LATE: @_ZTI6Test2a = linkonce_odr {{(dso_local )?}}constant103// CHECK-LATE: @_ZTS6Test2a = linkonce_odr {{(dso_local )?}}constant104 105void Test2a::bar() {}106inline void Test2a::foo() {}107 108/*** Test2b ******************************************************************/109 110struct Test2b {111  Test2b();112  virtual void foo();113  virtual void bar();114};115 116void Test2b::bar() {}117 118// V-table should be defined with weak linkage.119Test2b::Test2b() { use(typeid(Test2b)); }120// CHECK:      @_ZTV6Test2b = linkonce_odr {{(dso_local )?}}unnamed_addr constant121// CHECK-LATE: @_ZTI6Test2b = linkonce_odr {{(dso_local )?}}constant122// CHECK-LATE: @_ZTS6Test2b = linkonce_odr {{(dso_local )?}}constant123 124inline void Test2b::foo() {}125 126/*** Test2c ******************************************************************/127 128struct Test2c {129  Test2c();130  virtual void foo();131  virtual void bar();132};133 134void Test2c::bar() {}135inline void Test2c::foo() {}136 137// V-table should be defined with weak linkage.138Test2c::Test2c() { use(typeid(Test2c)); }139// CHECK: @_ZTV6Test2c = linkonce_odr {{(dso_local )?}}unnamed_addr constant140// CHECK: @_ZTI6Test2c = linkonce_odr {{(dso_local )?}}constant141// CHECK: @_ZTS6Test2c = linkonce_odr {{(dso_local )?}}constant142 143/*** Test3a ******************************************************************/144 145struct Test3a {146  Test3a();147  virtual void foo();148  virtual void bar();149};150 151// V-table should be defined with weak linkage.152Test3a::Test3a() { use(typeid(Test3a)); }153// CHECK:      @_ZTV6Test3a = linkonce_odr {{(dso_local )?}}unnamed_addr constant154// CHECK-LATE: @_ZTI6Test3a = linkonce_odr {{(dso_local )?}}constant155// CHECK-LATE: @_ZTS6Test3a = linkonce_odr {{(dso_local )?}}constant156 157// This defines the key function.158inline void Test3a::bar() {}159inline void Test3a::foo() {}160 161/*** Test3b ******************************************************************/162 163struct Test3b {164  Test3b();165  virtual void foo();166  virtual void bar();167};168 169inline void Test3b::bar() {}170 171// V-table should be defined with weak linkage.172Test3b::Test3b() { use(typeid(Test3b)); }173// CHECK:      @_ZTV6Test3b = linkonce_odr {{(dso_local )?}}unnamed_addr constant174// CHECK-LATE: @_ZTI6Test3b = linkonce_odr {{(dso_local )?}}constant175// CHECK-LATE: @_ZTS6Test3b = linkonce_odr {{(dso_local )?}}constant176 177// This defines the key function.178inline void Test3b::foo() {}179 180/*** Test3c ******************************************************************/181 182struct Test3c {183  Test3c();184  virtual void foo();185  virtual void bar();186};187 188// This defines the key function.189inline void Test3c::bar() {}190inline void Test3c::foo() {}191 192// V-table should be defined with weak linkage.193Test3c::Test3c() { use(typeid(Test3c)); }194// CHECK: @_ZTV6Test3c = linkonce_odr {{(dso_local )?}}unnamed_addr constant195// CHECK: @_ZTI6Test3c = linkonce_odr {{(dso_local )?}}constant196// CHECK: @_ZTS6Test3c = linkonce_odr {{(dso_local )?}}constant197