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: DW_TAG_structure_type
8 
9 template <typename T>
10 struct a {
11 };
12 extern template class a<int>;
13 // CHECK-NOT: ; [ DW_TAG_structure_type ] [a<int>]
14 
15 template <typename T>
16 struct b {
17 };
18 extern template class b<int>;
19 b<int> bi;
20 // CHECK: ; [ DW_TAG_structure_type ] [b<int>] {{.*}} [def]
21 
22 template <typename T>
23 struct c {
fc24   void f() {}
25 };
26 extern template class c<int>;
27 c<int> ci;
28 // CHECK: ; [ DW_TAG_structure_type ] [c<int>] {{.*}} [decl]
29 
30 template <typename T>
31 struct d {
32   void f();
33 };
34 extern template class d<int>;
35 d<int> di;
36 // CHECK: ; [ DW_TAG_structure_type ] [d<int>] {{.*}} [def]
37 
38 template <typename T>
39 struct e {
40   void f();
41 };
42 template <typename T>
f()43 void e<T>::f() {
44 }
45 extern template class e<int>;
46 e<int> ei;
47 // There's no guarantee that the out of line definition will appear before the
48 // explicit template instantiation definition, so conservatively emit the type
49 // definition here.
50 // CHECK: ; [ DW_TAG_structure_type ] [e<int>] {{.*}} [def]
51 
52 template <typename T>
53 struct f {
54   void g();
55 };
56 extern template class f<int>;
57 template <typename T>
g()58 void f<T>::g() {
59 }
60 f<int> fi;
61 // CHECK: ; [ DW_TAG_structure_type ] [f<int>] {{.*}} [def]
62 
63 template <typename T>
64 struct g {
65   void f();
66 };
67 template <>
68 void g<int>::f();
69 extern template class g<int>;
70 g<int> gi;
71 // CHECK: ; [ DW_TAG_structure_type ] [g<int>] {{.*}} [def]
72 
73 template <typename T>
74 struct h {
75 };
76 template class h<int>;
77 // CHECK: ; [ DW_TAG_structure_type ] [h<int>] {{.*}} [def]
78 
79 template <typename T>
80 struct i {
fi81   void f() {}
82 };
83 template<> void i<int>::f();
84 extern template class i<int>;
85 i<int> ii;
86 // CHECK: ; [ DW_TAG_structure_type ] [i<int>] {{.*}} [def]
87 
88 template <typename T1, typename T2 = T1>
89 struct j {
90 };
91 extern template class j<int>;
92 j<int> jj;
93 // CHECK: ; [ DW_TAG_structure_type ] [j<int, int>]
94 
95 template <typename T>
96 struct k {
97 };
98 template <>
99 struct k<int>;
100 template struct k<int>;
101 // CHECK-NOT: ; [ DW_TAG_structure_type ] [k<int>]
102