Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s |
| 2 | #include <typeinfo> |
Anders Carlsson | 4e71356 | 2009-12-11 16:37:06 +0000 | [diff] [blame] | 3 | |
| 4 | // CHECK: _ZTS1B = constant |
| 5 | // CHECK: _ZTS1A = weak_odr constant |
| 6 | // CHECK: _ZTI1A = weak_odr constant |
| 7 | // CHECK: _ZTI1B = constant |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 8 | // CHECK: _ZTSP1C = internal constant |
Anders Carlsson | 625c1ae | 2009-12-21 00:41:42 +0000 | [diff] [blame] | 9 | // CHECK: _ZTS1C = internal constant |
| 10 | // CHECK: _ZTI1C = internal constant |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 11 | // CHECK: _ZTIP1C = internal constant |
| 12 | // CHECK: _ZTSPP1C = internal constant |
| 13 | // CHECK: _ZTIPP1C = internal constant |
Anders Carlsson | 17fa6f9 | 2009-12-20 23:37:55 +0000 | [diff] [blame] | 14 | // CHECK: _ZTSM1Ci = internal constant |
| 15 | // CHECK: _ZTIM1Ci = internal constant |
| 16 | // CHECK: _ZTSPM1Ci = internal constant |
| 17 | // CHECK: _ZTIPM1Ci = internal constant |
| 18 | // CHECK: _ZTSM1CS_ = internal constant |
| 19 | // CHECK: _ZTIM1CS_ = internal constant |
| 20 | // CHECK: _ZTSM1CPS_ = internal constant |
| 21 | // CHECK: _ZTIM1CPS_ = internal constant |
| 22 | // CHECK: _ZTSM1A1C = internal constant |
| 23 | // CHECK: _ZTIM1A1C = internal constant |
| 24 | // CHECK: _ZTSM1AP1C = internal constant |
| 25 | // CHECK: _ZTIM1AP1C = internal constant |
| 26 | |
Anders Carlsson | e8f9038 | 2009-12-31 19:36:25 +0000 | [diff] [blame] | 27 | // CHECK: _ZTS1F = weak_odr constant |
| 28 | |
Anders Carlsson | 610b0d9 | 2009-12-21 00:57:38 +0000 | [diff] [blame] | 29 | // CHECK: _ZTSN12_GLOBAL__N_11DE = internal constant |
| 30 | // CHECK: _ZTIN12_GLOBAL__N_11DE = internal constant |
| 31 | // CHECK: _ZTSPN12_GLOBAL__N_11DE = internal constant |
| 32 | // CHECK: _ZTIPN12_GLOBAL__N_11DE = internal constant |
Anders Carlsson | 09b6e6e | 2009-12-29 20:20:19 +0000 | [diff] [blame] | 33 | // CHECK: _ZTSFN12_GLOBAL__N_11DEvE = internal constant |
| 34 | // CHECK: _ZTIFN12_GLOBAL__N_11DEvE = internal constant |
| 35 | // CHECK: _ZTSFvN12_GLOBAL__N_11DEE = internal constant |
| 36 | // CHECK: _ZTIFvN12_GLOBAL__N_11DEE = internal constant |
| 37 | |
| 38 | // CHECK: _ZTSPFvvE = weak_odr constant |
| 39 | // CHECK: _ZTSFvvE = weak_odr constant |
| 40 | // CHECK: _ZTIFvvE = weak_odr |
| 41 | // CHECK: _ZTIPFvvE = weak_odr constant |
Anders Carlsson | 610b0d9 | 2009-12-21 00:57:38 +0000 | [diff] [blame] | 42 | |
Anders Carlsson | 9c7b6bb | 2009-12-29 22:13:01 +0000 | [diff] [blame] | 43 | // CHECK: _ZTSN12_GLOBAL__N_11EE = internal constant |
| 44 | // CHECK: _ZTIN12_GLOBAL__N_11EE = internal constant |
| 45 | |
Anders Carlsson | 4e71356 | 2009-12-11 16:37:06 +0000 | [diff] [blame] | 46 | // A has no key function, so its RTTI data should be weak_odr. |
| 47 | struct A { }; |
| 48 | |
| 49 | // B has a key function defined in the translation unit, so the RTTI data should |
| 50 | // be emitted in this translation unit and have external linkage. |
| 51 | struct B : A { |
| 52 | virtual void f(); |
| 53 | }; |
| 54 | void B::f() { } |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 55 | |
| 56 | // C is an incomplete class type, so any direct or indirect pointer types should have |
Anders Carlsson | f64531a | 2009-12-30 01:00:12 +0000 | [diff] [blame] | 57 | // internal linkage, as should the type info for C itself. |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 58 | struct C; |
| 59 | |
Anders Carlsson | 610b0d9 | 2009-12-21 00:57:38 +0000 | [diff] [blame] | 60 | void t1() { |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 61 | (void)typeid(C*); |
| 62 | (void)typeid(C**); |
Anders Carlsson | 17fa6f9 | 2009-12-20 23:37:55 +0000 | [diff] [blame] | 63 | (void)typeid(int C::*); |
| 64 | (void)typeid(int C::**); |
| 65 | (void)typeid(C C::*); |
| 66 | (void)typeid(C *C::*); |
| 67 | (void)typeid(C A::*); |
| 68 | (void)typeid(C* A::*); |
Anders Carlsson | 8d14515 | 2009-12-20 22:30:54 +0000 | [diff] [blame] | 69 | } |
| 70 | |
Anders Carlsson | 610b0d9 | 2009-12-21 00:57:38 +0000 | [diff] [blame] | 71 | namespace { |
| 72 | // D is inside an anonymous namespace, so all type information related to D should have |
| 73 | // internal linkage. |
| 74 | struct D { }; |
Anders Carlsson | 9c7b6bb | 2009-12-29 22:13:01 +0000 | [diff] [blame] | 75 | |
| 76 | // E is also inside an anonymous namespace. |
| 77 | enum E { }; |
| 78 | |
Anders Carlsson | 610b0d9 | 2009-12-21 00:57:38 +0000 | [diff] [blame] | 79 | }; |
| 80 | |
Anders Carlsson | e8f9038 | 2009-12-31 19:36:25 +0000 | [diff] [blame] | 81 | // F has a key function defined in the translation unit, but it is inline so the RTTI |
| 82 | // data should be emitted with weak_odr linkage. |
| 83 | struct F { |
| 84 | virtual void f(); |
| 85 | }; |
| 86 | |
| 87 | inline void F::f() { } |
Douglas Gregor | f57f207 | 2009-12-23 20:51:04 +0000 | [diff] [blame] | 88 | const D getD(); |
| 89 | |
| 90 | const std::type_info &t2() { |
| 91 | (void)typeid(const D); |
Anders Carlsson | 09b6e6e | 2009-12-29 20:20:19 +0000 | [diff] [blame] | 92 | (void)typeid(D *); |
| 93 | (void)typeid(D (*)()); |
| 94 | (void)typeid(void (*)(D)); |
Douglas Gregor | 031b371 | 2010-03-31 00:15:35 +0000 | [diff] [blame^] | 95 | (void)typeid(void (*)(D&)); |
Anders Carlsson | 09b6e6e | 2009-12-29 20:20:19 +0000 | [diff] [blame] | 96 | // The exception specification is not part of the RTTI descriptor, so it should not have |
| 97 | // internal linkage. |
| 98 | (void)typeid(void (*)() throw (D)); |
| 99 | |
Anders Carlsson | 9c7b6bb | 2009-12-29 22:13:01 +0000 | [diff] [blame] | 100 | (void)typeid(E); |
| 101 | |
Douglas Gregor | f57f207 | 2009-12-23 20:51:04 +0000 | [diff] [blame] | 102 | // CHECK: _ZTIN12_GLOBAL__N_11DE to |
| 103 | return typeid(getD()); |
Anders Carlsson | 610b0d9 | 2009-12-21 00:57:38 +0000 | [diff] [blame] | 104 | } |