1 // RUN: clang-cc -I%S -triple x86_64-apple-darwin -std=c++0x -O0 -S %s -o %t.s
2 // RUN: FileCheck --input-file=%t.s %s
4 // RUN: clang-cc -I%S -triple x86_64-apple-darwin -std=c++0x -emit-llvm %s -o %t.ll
5 // RUN: FileCheck -check-prefix LL --input-file=%t.ll %s
10 virtual void foo() { }
12 class test1_B2 : public test1_B1 {
13 virtual void foo() { }
15 class test1_B3 : public test1_B2, public test1_B1 {
16 virtual void foo() { }
18 class test1_B4 : virtual public test1_B3 {
19 virtual void foo() { }
21 class test1_B5 : virtual test1_B3, test1_B4 {
22 virtual void foo() { }
25 virtual void foo() { }
27 class test1_B7 : public test1_B6, public test1_B5 {
28 virtual void foo() { }
30 class test1_D : public test1_B7 {
31 virtual void foo() { }
35 // CHECK-NEXT: .asciz "PVi"
38 // CHECK-NEXT: .quad (__ZTVN10__cxxabiv119__pointer_type_infoE) + 16
39 // CHECK-NEXT: .quad __ZTSPVi
40 // CHECK-NEXT: .long 2
41 // CHECK-NEXT: .space 4
42 // CHECK-NEXT: .quad __ZTIi
44 // CHECK: .globl __ZTS7test3_A
45 // CHECK-NEXT: .weak_definition __ZTS7test3_A
46 // CHECK: __ZTS7test3_A:
47 // CHECK-NEXT: .asciz "7test3_A"
49 // CHECK: __ZTIM7test3_Ai:
50 // CHECK-NEXT: .quad (__ZTVN10__cxxabiv129__pointer_to_member_type_infoE) + 16
51 // CHECK-NEXT: .quad __ZTSM7test3_Ai
52 // CHECK-NEXT: .space 4
53 // CHECK-NEXT: .space 4
54 // CHECK-NEXT: .quad __ZTIi
55 // CHECK-NEXT: .quad __ZTI7test3_A
57 // CHECK: __ZTIM7test3_Ii:
58 // CHECK-NEXT: .quad (__ZTVN10__cxxabiv129__pointer_to_member_type_infoE) + 16
59 // CHECK-NEXT: .quad __ZTSM7test3_Ii
60 // CHECK-NEXT: .long 16
61 // CHECK-NEXT: .space 4
62 // CHECK-NEXT: .quad __ZTIi
63 // CHECK-NEXT: .quad __ZTI7test3_I
65 // CHECK: .private_extern __ZTIFvvE
66 // CHECK: .globl __ZTIFvvE
67 // CHECK: .weak_definition __ZTIFvvE
69 // CHECK-NEXT: .quad (__ZTVN10__cxxabiv120__function_type_infoE) + 16
70 // CHECK-NEXT: .quad __ZTSFvvE
72 // CHECK: __ZTIM7test3_AFvvE:
73 // CHECK-NEXT: .quad (__ZTVN10__cxxabiv129__pointer_to_member_type_infoE) + 16
74 // CHECK-NEXT: .quad __ZTSM7test3_AFvvE
75 // CHECK-NEXT: .space 4
76 // CHECK-NEXT: .space 4
77 // CHECK-NEXT: .quad __ZTIFvvE
78 // CHECK-NEXT: .quad __ZTI7test3_A
82 // CHECK:__ZTI7test1_D:
83 // CHECK-NEXT: .quad (__ZTVN10__cxxabiv120__si_class_type_infoE) + 16
84 // CHECK-NEXT: .quad __ZTS7test1_D
85 // CHECK-NEXT: .quad __ZTI8test1_B7
87 // CHECK:__ZTI8test1_B7:
88 // CHECK-NEXT: .quad (__ZTVN10__cxxabiv121__vmi_class_type_infoE) + 16
89 // CHECK-NEXT: .quad __ZTS8test1_B7
90 // CHECK-NEXT: .long 3
91 // CHECK-NEXT: .long 2
92 // CHECK-NEXT: .quad __ZTI8test1_B6
93 // CHECK-NEXT: .quad 2
94 // CHECK-NEXT: .quad __ZTI8test1_B5
95 // CHECK-NEXT: .quad 2050
97 // CHECK:__ZTI8test1_B5:
98 // CHECK-NEXT: .quad (__ZTVN10__cxxabiv121__vmi_class_type_infoE) + 16
99 // CHECK-NEXT: .quad __ZTS8test1_B5
100 // CHECK-NEXT: .long 3
101 // CHECK-NEXT: .long 2
102 // CHECK-NEXT: .quad __ZTI8test1_B3
103 // CHECK-NEXT: .quad 18446744073709545473
104 // CHECK-NEXT: .quad __ZTI8test1_B4
105 // CHECK-NEXT: .space 8
107 // CHECK:__ZTI8test1_B4:
108 // CHECK-NEXT: .quad (__ZTVN10__cxxabiv121__vmi_class_type_infoE) + 16
109 // CHECK-NEXT: .quad __ZTS8test1_B4
110 // CHECK-NEXT: .long 1
111 // CHECK-NEXT: .long 1
112 // CHECK-NEXT: .quad __ZTI8test1_B3
113 // CHECK-NEXT: .quad 18446744073709545475
115 // CHECK:__ZTI8test1_B6:
116 // CHECK-NEXT: .quad (__ZTVN10__cxxabiv117__class_type_infoE) + 16
117 // CHECK-NEXT: .quad __ZTS8test1_B6
119 // CHECK:__ZTI8test1_B3:
120 // CHECK-NEXT: .quad (__ZTVN10__cxxabiv121__vmi_class_type_infoE) + 16
121 // CHECK-NEXT: .quad __ZTS8test1_B3
122 // CHECK-NEXT: .long 1
123 // CHECK-NEXT: .long 2
124 // CHECK-NEXT: .quad __ZTI8test1_B2
125 // CHECK-NEXT: .quad 2
126 // CHECK-NEXT: .quad __ZTI8test1_B1
127 // CHECK-NEXT: .quad 2050
129 // CHECK:__ZTS8test1_B1:
130 // CHECK-NEXT: .asciz "8test1_B1"
132 // CHECK:__ZTI8test1_B1:
133 // CHECK-NEXT: .quad (__ZTVN10__cxxabiv117__class_type_infoE) + 16
134 // CHECK-NEXT:. quad __ZTS8test1_B1
136 // CHECK:__ZTS8test1_B2:
137 // CHECK-NEXT: .asciz "8test1_B2"
139 // CHECK:__ZTI8test1_B2:
140 // CHECK-NEXT: .quad (__ZTVN10__cxxabiv120__si_class_type_infoE) + 16
141 // CHECK-NEXT: .quad __ZTS8test1_B2
142 // CHECK-NEXT: .quad __ZTI8test1_B1
147 void test2_2(test1_D *dp) {
149 if (typeid(d) == typeid(test1_D))
151 if (typeid(NP) == typeid(test1_D))
153 if (typeid(((*(dp)))) == typeid(test1_D))
155 if (typeid(int) == typeid(float))
157 if (typeid(int*) == typeid(const int *))
161 // CHECK-LL:define void @_Z7test2_2P7test1_D(%class.test1_B7* %dp) nounwind {
162 // CHECK-LL: %tmp1 = load %class.test1_B7** %d
163 // CHECK-LL-NEXT: %0 = bitcast %class.test1_B7* %tmp1 to %"class.std::type_info"***
164 // CHECK-LL-NEXT: %vtable = load %"class.std::type_info"*** %0
165 // CHECK-LL-NEXT: %1 = getelementptr inbounds %"class.std::type_info"** %vtable, i64 -1
166 // CHECK-LL-NEXT: %2 = load %"class.std::type_info"** %1
167 // CHECK-LL-NEXT: %call = call zeroext i1 @_ZNKSt9type_infoeqERKS_(%"class.std::type_info"* %2, %"class.std::type_info"* bitcast (%{{[0-9]*}}* @_ZTI7test1_D to %"class.std::type_info"*))
169 // CHECK-LL: %call2 = call zeroext i1 @_ZNKSt9type_infoeqERKS_(%"class.std::type_info"* bitcast (%0* @_ZTI2NP to %"class.std::type_info"*), %"class.std::type_info"* bitcast (%{{[0-9]*}}* @_ZTI7test1_D to %"class.std::type_info"*))
171 // CHECK-LL: %3 = bitcast %class.test1_B7* %tmp5 to %"class.std::type_info"***
172 // CHECK-LL-NEXT: %4 = icmp ne %"class.std::type_info"*** %3, null
173 // CHECK-LL-NEXT: br i1 %4, label %6, label %5
174 // CHECK-LL: ; <label>:5
175 // CHECK-LL-NEXT: call void @__cxa_bad_typeid()
176 // CHECK-LL-NEXT: unreachable
177 // CHECK-LL: ; <label>:6
178 // CHECK-LL-NEXT: %vtable6 = load %"class.std::type_info"*** %3
179 // CHECK-LL-NEXT: %7 = getelementptr inbounds %"class.std::type_info"** %vtable6, i64 -1
180 // CHECK-LL-NEXT: %8 = load %"class.std::type_info"** %7
181 // CHECK-LL-NEXT: %call7 = call zeroext i1 @_ZNKSt9type_infoeqERKS_(%"class.std::type_info"* %8, %"class.std::type_info"* bitcast (%{{[0-9]*}}* @_ZTI7test1_D to %"class.std::type_info"*))
183 // CHECK-LL: %call10 = call zeroext i1 @_ZNKSt9type_infoeqERKS_(%"class.std::type_info"* bitcast (i8** @_ZTIi to %"class.std::type_info"*), %"class.std::type_info"* bitcast (i8** @_ZTIf to %"class.std::type_info"*))
185 // CHECK-LL: %call13 = call zeroext i1 @_ZNKSt9type_infoeqERKS_(%"class.std::type_info"* bitcast (i8** @_ZTIPi to %"class.std::type_info"*), %"class.std::type_info"* bitcast (i8** @_ZTIPKi to %"class.std::type_info"*))
190 int (test3_I::*i_pmd);
191 void (test3_A::*pmf)();
193 if (typeid(volatile int *) == typeid(int *))
195 if (typeid(pmd) == typeid(i_pmd))
197 if (typeid(pmd) == typeid(pmf))
201 if (typeid(int[5]) == typeid(enum a))
205 bool test4(std::type_info* __pointee) {
206 return *__pointee == typeid (void);