1 // RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple -debug-info-kind=limited %s -o - | FileCheck %s
2 
3 // Run again with -gline-tables-only and verify we don't crash.  We won't output
4 // type info at all.
5 // RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple -debug-info-kind=line-tables-only %s -o - | FileCheck %s -check-prefix LINES-ONLY
6 
7 // LINES-ONLY-NOT: !DICompositeType(tag: DW_TAG_structure_type
8 
9 // "h" is at the top because it's in the compile unit's retainedTypes: list.
10 // CHECK: DICompositeType(tag: DW_TAG_structure_type, name: "h<int>"
11 // CHECK-NOT: DIFlagFwdDecl
12 // CHECK-SAME: ){{$}}
13 
14 template <typename T>
15 struct a {
16 };
17 extern template class a<int>;
18 // CHECK-NOT: DICompositeType(tag: DW_TAG_structure_type, name: "a<int>"
19 
20 template <typename T>
21 struct b {
22 };
23 extern template class b<int>;
24 b<int> bi;
25 // CHECK: DICompositeType(tag: DW_TAG_structure_type, name: "b<int>"
26 // CHECK-NOT: DIFlagFwdDecl
27 // CHECK-SAME: ){{$}}
28 
29 template <typename T>
30 struct c {
31   void f() {}
32 };
33 extern template class c<int>;
34 c<int> ci;
35 // CHECK: DICompositeType(tag: DW_TAG_structure_type, name: "c<int>"
36 // CHECK-SAME: DIFlagFwdDecl
37 
38 template <typename T>
39 struct d {
40   void f();
41 };
42 extern template class d<int>;
43 d<int> di;
44 // CHECK: DICompositeType(tag: DW_TAG_structure_type, name: "d<int>"
45 // CHECK-NOT: DIFlagFwdDecl
46 // CHECK-SAME: ){{$}}
47 
48 template <typename T>
49 struct e {
50   void f();
51 };
52 template <typename T>
53 void e<T>::f() {
54 }
55 extern template class e<int>;
56 e<int> ei;
57 // There's no guarantee that the out of line definition will appear before the
58 // explicit template instantiation definition, so conservatively emit the type
59 // definition here.
60 // CHECK: DICompositeType(tag: DW_TAG_structure_type, name: "e<int>"
61 // CHECK-NOT: DIFlagFwdDecl
62 // CHECK-SAME: ){{$}}
63 
64 template <typename T>
65 struct f {
66   void g();
67 };
68 extern template class f<int>;
69 template <typename T>
70 void f<T>::g() {
71 }
72 f<int> fi;
73 // CHECK: DICompositeType(tag: DW_TAG_structure_type, name: "f<int>"
74 // CHECK-NOT: DIFlagFwdDecl
75 // CHECK-SAME: ){{$}}
76 
77 template <typename T>
78 struct g {
79   void f();
80 };
81 template <>
82 void g<int>::f();
83 extern template class g<int>;
84 g<int> gi;
85 // CHECK: DICompositeType(tag: DW_TAG_structure_type, name: "g<int>"
86 // CHECK-NOT: DIFlagFwdDecl
87 // CHECK-SAME: ){{$}}
88 
89 template <typename T>
90 struct h {
91 };
92 template class h<int>;
93 
94 template <typename T>
95 struct i {
96   void f() {}
97 };
98 template<> void i<int>::f();
99 extern template class i<int>;
100 i<int> ii;
101 // CHECK: DICompositeType(tag: DW_TAG_structure_type, name: "i<int>"
102 // CHECK-NOT: DIFlagFwdDecl
103 // CHECK-SAME: ){{$}}
104 
105 template <typename T1, typename T2 = T1>
106 struct j {
107 };
108 extern template class j<int>;
109 j<int> jj;
110 // CHECK: DICompositeType(tag: DW_TAG_structure_type, name: "j<int, int>"
111 
112 template <typename T>
113 struct k {
114 };
115 template <>
116 struct k<int>;
117 template struct k<int>;
118 // CHECK-NOT: !DICompositeType(tag: DW_TAG_structure_type, name: "k<int>"
119