1 // RUN: %clang_cc1 %s -triple=x86_64-pc-windows-msvc -debug-info-kind=limited -S -emit-llvm -o - | FileCheck %s
2 // RUN: %clang_cc1 %s -triple %itanium_abi_triple -debug-info-kind=limited -S -emit-llvm -o - | FileCheck %s -check-prefix=ITANIUM
4 // Validate we emit a "DIFlagThunk" flag on DISubprogram entries for thunks.
5 // This flag is used for emitting S_THUNK32 symbols for CodeView debugging.
8 // Because thunks are compiler generated and don't exist in the source, this
9 // test is dependent upon the linkage name to identify the thunk. Any changes
10 // in the name mangling may require this test to be updated.
13 // The FileCheck directives below use CHECK-DAG because the thunks may not be
14 // emitted in source order.
32 // CHECK-DAG: DISubprogram{{.*}}linkageName: "?f@C@Test1@@W7EAAXXZ"{{.*}} flags: {{.*}}DIFlagThunk
38 struct V2 : virtual V1 { };
50 // CHECK-DAG: DISubprogram{{.*}}linkageName: "?f@B@Test2@@QEAAPEAUV1@2@XZ"{{.*}} flags: {{.*}}DIFlagThunk
51 V2 *B::f() { return 0; }
63 struct __attribute__((visibility("protected"))) C : A, B {
69 // CHECK-DAG: DISubprogram{{.*}}linkageName: "?f@C@Test3@@W7EAAXXZ"{{.*}} flags: {{.*}}DIFlagThunk
89 // CHECK-DAG: DISubprogram{{.*}}linkageName: "?f@C@?A@Test4@@W7EAAXXZ"{{.*}} flags: {{.*}}DIFlagThunk
92 // Force C::f to be used.
103 X &operator=(const X&);
120 virtual X f() { return X(); }
126 virtual X f() { return X(); }
129 struct Thunks : Base1, Base2 {
135 // CHECK-DAG: DISubprogram{{.*}}linkageName: "?f@Thunks@Test5@@WBA@EAA?AUX@2@XZ"{{.*}} flags: {{.*}}DIFlagThunk
136 X Thunks::f() { return X(); }
143 X &operator=(const X&);
147 struct Small { short s; };
154 virtual void foo() = 0;
159 virtual void bar() = 0;
164 virtual void baz(X, X&, _Complex float, Small, Small&, Large) = 0;
169 // CHECK-DAG: DISubprogram{{.*}}linkageName: "?foo@D@Test6@@G7EAAXXZ"{{.*}} flags: {{.*}}DIFlagThunk
172 void baz(X, X&, _Complex float, Small, Small&, Large);
175 void D::baz(X, X&, _Complex float, Small, Small&, Large) { }
177 void testD() { D d; }
181 struct A { virtual void foo(); };
182 struct B { virtual void foo(); };
183 // CHECK-DAG: DISubprogram{{.*}}linkageName: "?foo@C@Test7@@W7EAAXXZ"{{.*}} flags: {{.*}}DIFlagThunk
184 struct C : A, B { void foo() {} };
193 struct A { virtual A* f(); };
194 struct B : virtual A { virtual A* f(); };
195 struct C : B { virtual C* f(); };
196 // CHECK-DAG: DISubprogram{{.*}}linkageName: "?f@C@Test8@@QEAAPEAUA@2@XZ"{{.*}} flags: {{.*}}DIFlagThunk
197 C* C::f() { return 0; }
207 struct Proxy1 : Pad1, B1 {
210 struct D : virtual Proxy1 {
214 // CHECK-DAG: DISubprogram{{.*}}linkageName: "?foo1@D@Test9@@$4PPPPPPPE@A@EAAAEAUB1@2@XZ"{{.*}} flags: {{.*}}DIFlagThunk
215 // CHECK-DAG: DISubprogram{{.*}}linkageName: "?foo1@D@Test9@@$4PPPPPPPE@A@EAAAEAU12@XZ"{{.*}} flags: {{.*}}DIFlagThunk
228 class C : public A, public B {
231 // CHECK-DAG: DISubprogram{{.*}}linkageName: "?f@C@Test10@@G7EAAXXZ"{{.*}} flags: {{.*}}DIFlagThunk
243 // CHECK-DAG: DISubprogram{{.*}}linkageName: "??_9A@Test11@@$BA@AA"{{.*}} flags: {{.*}}DIFlagThunk
244 void (A::*p)() = &A::f;
262 // ITANIUM: define {{.*}}void @_ZThn{{[48]}}_N6Test121C1fEv
263 // ITANIUM-SAME: !dbg ![[SP:[0-9]+]]
264 // ITANIUM-NOT: {{ret }}
265 // ITANIUM: = load{{.*}} !dbg ![[DBG:[0-9]+]]
266 // ITANIUM-NOT: {{ret }}
267 // ITANIUM: ret void, !dbg ![[DBG]]
269 // ITANIUM: ![[SP]] = distinct !DISubprogram(linkageName: "_ZThn{{[48]}}_N6Test121C1fEv"
270 // ITANIUM-SAME: line: 261
271 // ITANIUM-SAME: isDefinition: true
272 // ITANIUM-SAME: DIFlagArtificial
273 // ITANIUM-SAME: DIFlagThunk
274 // ITANIUM-SAME: ){{$}}
276 // ITANIUM: ![[DBG]] = !DILocation(line: 0