1 // RUN: %clang_cc1 -DSETATTR=0 -triple x86_64-unknown-linux-gnu -emit-llvm -debug-info-kind=constructor %s -o - | FileCheck %s --check-prefix=DEBUG
2 // RUN: %clang_cc1 -DSETATTR=1 -triple x86_64-unknown-linux-gnu -emit-llvm -debug-info-kind=constructor %s -o - | FileCheck %s --check-prefix=WITHATTR
3 // Use -debug-info-kind=constructor because it includes all the optimizations.
4 
5 #if SETATTR
6 #define STANDALONEDEBUGATTR __attribute__((standalone_debug))
7 #else
8 #define STANDALONEDEBUGATTR
9 #endif
10 
11 struct STANDALONEDEBUGATTR StructWithConstructor {
StructWithConstructorStructWithConstructor12   StructWithConstructor() {}
13 };
f(StructWithConstructor s)14 void f(StructWithConstructor s) {}
15 // DEBUG:  !DICompositeType({{.*}}name: "StructWithConstructor"
16 // DEBUG-SAME:              flags: {{.*}}DIFlagFwdDecl
17 // WITHATTR: !DICompositeType({{.*}}name: "StructWithConstructor"
18 // WITHATTR-NOT: DIFlagFwdDecl
19 
20 union STANDALONEDEBUGATTR UnionWithConstructor {
UnionWithConstructor()21   UnionWithConstructor() {}
22 };
f(UnionWithConstructor u)23 void f(UnionWithConstructor u) {}
24 // DEBUG:  !DICompositeType({{.*}}name: "UnionWithConstructor"
25 // DEBUG-SAME:              flags: {{.*}}DIFlagFwdDecl
26 // WITHATTR: !DICompositeType({{.*}}name: "UnionWithConstructor"
27 // WITHATTR-NOT: DIFlagFwdDecl
28 
29 template <typename T> struct ExternTemplate {
ExternTemplateExternTemplate30   ExternTemplate() {}
31   T x;
32 };
33 extern template struct STANDALONEDEBUGATTR ExternTemplate<int>;
f(ExternTemplate<int> s)34 void f(ExternTemplate<int> s) {}
35 // DEBUG: !DICompositeType({{.*}}name: "ExternTemplate<int>"
36 // DEBUG-SAME:             flags: {{.*}}DIFlagFwdDecl
37 // WITHATTR: !DICompositeType({{.*}}name: "ExternTemplate<int>"
38 // WITHATTR-NOT: DIFlagFwdDecl
39 
40 struct STANDALONEDEBUGATTR CompleteTypeRequired {};
f(CompleteTypeRequired & s)41 void f(CompleteTypeRequired &s) {}
42 // DEBUG: !DICompositeType({{.*}}name: "CompleteTypeRequired"
43 // DEBUG-SAME:             flags: {{.*}}DIFlagFwdDecl
44 // WITHATTR: !DICompositeType({{.*}}name: "CompleteTypeRequired"
45 // WITHATTR-NOT: DIFlagFwdDecl
46 
47 struct STANDALONEDEBUGATTR Redecl;
48 struct Redecl {};
f(Redecl & s)49 void f(Redecl &s) {}
50 // DEBUG: !DICompositeType({{.*}}name: "Redecl"
51 // DEBUG-SAME:             flags: {{.*}}DIFlagFwdDecl
52 // WITHATTR: !DICompositeType({{.*}}name: "Redecl"
53 // WITHATTR-NOT: DIFlagFwdDecl
54 
55