1 // RUN: %clang_cc1 %std_cxx98- %s -I%S -triple=x86_64-apple-darwin10 -emit-llvm -Wno-dynamic-exception-spec -o - | FileCheck %s -check-prefixes=CHECK,CHECK-BOTH
2 // RUN: %clang_cc1 %std_cxx98- %s -I%S -triple=x86_64-apple-darwin10 -emit-llvm -Wno-dynamic-exception-spec -fvisibility=hidden -o - | FileCheck %s --check-prefixes=CHECK-WITH-HIDDEN,CHECK-BOTH
6 // CHECK-BOTH: _ZTSP1C = internal constant
7 // CHECK-BOTH: _ZTS1C = internal constant
8 // CHECK-BOTH: _ZTI1C = internal constant
9 // CHECK-BOTH: _ZTIP1C = internal constant
10 // CHECK-BOTH: _ZTSPP1C = internal constant
11 // CHECK-BOTH: _ZTIPP1C = internal constant
12 // CHECK-BOTH: _ZTSM1Ci = internal constant
13 // CHECK-BOTH: _ZTIM1Ci = internal constant
14 // CHECK-BOTH: _ZTSPM1Ci = internal constant
15 // CHECK-BOTH: _ZTIPM1Ci = internal constant
16 // CHECK-BOTH: _ZTSM1CS_ = internal constant
17 // CHECK-BOTH: _ZTIM1CS_ = internal constant
18 // CHECK-BOTH: _ZTSM1CPS_ = internal constant
19 // CHECK-BOTH: _ZTIM1CPS_ = internal constant
20 // CHECK-BOTH: _ZTSM1A1C = internal constant
21 // CHECK: _ZTS1A = linkonce_odr constant
22 // CHECK-WITH-HIDDEN: _ZTS1A = linkonce_odr hidden constant
23 // CHECK: _ZTI1A = linkonce_odr constant
24 // CHECK-WITH-HIDDEN: _ZTI1A = linkonce_odr hidden constant
25 // CHECK-BOTH: _ZTIM1A1C = internal constant
26 // CHECK-BOTH: _ZTSM1AP1C = internal constant
27 // CHECK-BOTH: _ZTIM1AP1C = internal constant
29 // CHECK-WITH-HIDDEN: _ZTSFN12_GLOBAL__N_11DEvE = internal constant
30 // CHECK-WITH-HIDDEN: @_ZTSPK2T4 = linkonce_odr hidden constant
31 // CHECK-WITH-HIDDEN: @_ZTS2T4 = linkonce_odr hidden constant
32 // CHECK-WITH-HIDDEN: @_ZTI2T4 = linkonce_odr hidden constant
33 // CHECK-WITH-HIDDEN: @_ZTIPK2T4 = linkonce_odr hidden constant
34 // CHECK-WITH-HIDDEN: @_ZTSZ2t5vE1A = internal constant
35 // CHECK-WITH-HIDDEN: @_ZTIZ2t5vE1A = internal constant
36 // CHECK-WITH-HIDDEN: @_ZTSZ2t6vE1A = linkonce_odr hidden constant
37 // CHECK-WITH-HIDDEN: @_ZTIZ2t6vE1A = linkonce_odr hidden constant
38 // CHECK-WITH-HIDDEN: @_ZTSPZ2t7vE1A = linkonce_odr hidden constant
39 // CHECK-WITH-HIDDEN: @_ZTSZ2t7vE1A = linkonce_odr hidden constant
40 // CHECK-WITH-HIDDEN: @_ZTIZ2t7vE1A = linkonce_odr hidden constant
41 // CHECK-WITH-HIDDEN: @_ZTIPZ2t7vE1A = linkonce_odr hidden constant
43 // CHECK: _ZTSN12_GLOBAL__N_11DE = internal constant
44 // CHECK: _ZTIN12_GLOBAL__N_11DE = internal constant
45 // CHECK: _ZTSPN12_GLOBAL__N_11DE = internal constant
46 // CHECK: _ZTIPN12_GLOBAL__N_11DE = internal constant
47 // CHECK: _ZTSFN12_GLOBAL__N_11DEvE = internal constant
48 // CHECK: _ZTIFN12_GLOBAL__N_11DEvE = internal constant
49 // CHECK: _ZTSFvN12_GLOBAL__N_11DEE = internal constant
50 // CHECK: _ZTIFvN12_GLOBAL__N_11DEE = internal constant
51 // CHECK: _ZTSPFvvE = linkonce_odr constant
52 // CHECK: _ZTSFvvE = linkonce_odr constant
53 // CHECK: _ZTIFvvE = linkonce_odr constant
54 // CHECK: _ZTIPFvvE = linkonce_odr constant
55 // CHECK: _ZTSN12_GLOBAL__N_11EE = internal constant
56 // CHECK: _ZTIN12_GLOBAL__N_11EE = internal constant
57 // CHECK: _ZTSA10_i = linkonce_odr constant
58 // CHECK: _ZTIA10_i = linkonce_odr constant
59 // CHECK: _ZTI1TILj0EE = linkonce_odr constant
60 // CHECK: _ZTI1TILj1EE = weak_odr constant
61 // CHECK: _ZTI1TILj2EE = external constant
62 // CHECK: _ZTSZ2t5vE1A = internal constant
63 // CHECK: _ZTIZ2t5vE1A = internal constant
64 // CHECK: _ZTS1B ={{.*}} constant
65 // CHECK: _ZTI1B ={{.*}} constant
66 // CHECK: _ZTS1F = linkonce_odr constant
67 // CHECK: _ZTSZ2t6vE1A = linkonce_odr constant
68 // CHECK: _ZTIZ2t6vE1A = linkonce_odr constant
69 // CHECK: _ZTSPZ2t7vE1A = linkonce_odr constant
70 // CHECK: _ZTSZ2t7vE1A = linkonce_odr constant
71 // CHECK: _ZTIZ2t7vE1A = linkonce_odr constant
72 // CHECK: _ZTIPZ2t7vE1A = linkonce_odr constant
74 // CHECK: _ZTIN12_GLOBAL__N_11DE
76 // A has no key function, so its RTTI data should be linkonce_odr.
79 // B has a key function defined in the translation unit, so the RTTI data should
80 // be emitted in this translation unit and have external linkage.
86 // C is an incomplete class type, so any direct or indirect pointer types should have
87 // internal linkage, as should the type info for C itself.
93 (void)typeid(int C::*);
94 (void)typeid(int C::**);
96 (void)typeid(C
*C::*);
98 (void)typeid(C
* A::*);
102 // D is inside an anonymous namespace, so all type information related to D should have
106 // E is also inside an anonymous namespace.
111 // F has a key function defined in the translation unit, but it is inline so the RTTI
112 // data should be emitted with linkonce_odr linkage.
117 inline void F::f() { }
120 const std::type_info
&t2() {
121 (void)typeid(const D
);
123 (void)typeid(D (*)());
124 (void)typeid(void (*)(D
));
125 (void)typeid(void (*)(D
&));
126 // The exception specification is not part of the RTTI descriptor, so it should not have
128 (void)typeid(void (*)() throw (D
));
132 return typeid(getD());
137 static const int a
[10];
139 const std::type_info
&f() {
144 template <unsigned N
> class T
{
145 virtual void anchor() {}
148 template <> class T
<2> { virtual void anchor(); };
156 void t4(const T4
*ptr
) {
157 const void *value
= &typeid(ptr
);
162 const void *value
= &typeid(A
);
167 const void *value
= &typeid(A
);
175 const void *value
= &typeid(A
*);