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: !MDCompositeType(tag: DW_TAG_structure_type
8
9template <typename T>
10struct a {
11};
12extern template class a<int>;
13// CHECK-NOT: MDCompositeType(tag: DW_TAG_structure_type, name: "a<int>"
14
15template <typename T>
16struct b {
17};
18extern template class b<int>;
19b<int> bi;
20// CHECK: MDCompositeType(tag: DW_TAG_structure_type, name: "b<int>"
21// CHECK-NOT: DIFlagFwdDecl
22// CHECK-SAME: ){{$}}
23
24template <typename T>
25struct c {
26  void f() {}
27};
28extern template class c<int>;
29c<int> ci;
30// CHECK: MDCompositeType(tag: DW_TAG_structure_type, name: "c<int>"
31// CHECK-SAME: DIFlagFwdDecl
32
33template <typename T>
34struct d {
35  void f();
36};
37extern template class d<int>;
38d<int> di;
39// CHECK: MDCompositeType(tag: DW_TAG_structure_type, name: "d<int>"
40// CHECK-NOT: DIFlagFwdDecl
41// CHECK-SAME: ){{$}}
42
43template <typename T>
44struct e {
45  void f();
46};
47template <typename T>
48void e<T>::f() {
49}
50extern template class e<int>;
51e<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: MDCompositeType(tag: DW_TAG_structure_type, name: "e<int>"
56// CHECK-NOT: DIFlagFwdDecl
57// CHECK-SAME: ){{$}}
58
59template <typename T>
60struct f {
61  void g();
62};
63extern template class f<int>;
64template <typename T>
65void f<T>::g() {
66}
67f<int> fi;
68// CHECK: MDCompositeType(tag: DW_TAG_structure_type, name: "f<int>"
69// CHECK-NOT: DIFlagFwdDecl
70// CHECK-SAME: ){{$}}
71
72template <typename T>
73struct g {
74  void f();
75};
76template <>
77void g<int>::f();
78extern template class g<int>;
79g<int> gi;
80// CHECK: MDCompositeType(tag: DW_TAG_structure_type, name: "g<int>"
81// CHECK-NOT: DIFlagFwdDecl
82// CHECK-SAME: ){{$}}
83
84template <typename T>
85struct h {
86};
87template class h<int>;
88// CHECK: MDCompositeType(tag: DW_TAG_structure_type, name: "h<int>"
89// CHECK-NOT: DIFlagFwdDecl
90// CHECK-SAME: ){{$}}
91
92template <typename T>
93struct i {
94  void f() {}
95};
96template<> void i<int>::f();
97extern template class i<int>;
98i<int> ii;
99// CHECK: MDCompositeType(tag: DW_TAG_structure_type, name: "i<int>"
100// CHECK-NOT: DIFlagFwdDecl
101// CHECK-SAME: ){{$}}
102
103template <typename T1, typename T2 = T1>
104struct j {
105};
106extern template class j<int>;
107j<int> jj;
108// CHECK: MDCompositeType(tag: DW_TAG_structure_type, name: "j<int, int>"
109
110template <typename T>
111struct k {
112};
113template <>
114struct k<int>;
115template struct k<int>;
116// CHECK-NOT: !MDCompositeType(tag: DW_TAG_structure_type, name: "k<int>"
117