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