Clang Project

clang_source_code/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp
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 or -gline-directives-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// RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple -debug-info-kind=line-directives-only %s -o - | FileCheck %s -check-prefix LINES-ONLY
7
8// LINES-ONLY-NOT: !DICompositeType(tag: DW_TAG_structure_type
9
10// "h" is at the top because it's in the compile unit's retainedTypes: list.
11// CHECK: DICompositeType(tag: DW_TAG_structure_type, name: "h<int>"
12// CHECK-NOT: DIFlagFwdDecl
13// CHECK-SAME: ){{$}}
14
15template <typename T>
16struct a {
17};
18extern template class a<int>;
19// CHECK-NOT: DICompositeType(tag: DW_TAG_structure_type, name: "a<int>"
20
21template <typename T>
22struct b {
23};
24extern template class b<int>;
25b<int> bi;
26
27template <typename T>
28struct c {
29  void f() {}
30};
31extern template class c<int>;
32c<int> ci;
33// CHECK: DICompositeType(tag: DW_TAG_structure_type, name: "c<int>"
34// CHECK-SAME: DIFlagFwdDecl
35
36template <typename T>
37struct d {
38  void f();
39};
40extern template class d<int>;
41d<int> di;
42// CHECK: DICompositeType(tag: DW_TAG_structure_type, name: "d<int>"
43// CHECK-NOT: DIFlagFwdDecl
44// CHECK-SAME: ){{$}}
45
46template <typename T>
47struct e {
48  void f();
49};
50template <typename T>
51void e<T>::f() {
52}
53extern template class e<int>;
54e<int> ei;
55// There's no guarantee that the out of line definition will appear before the
56// explicit template instantiation definition, so conservatively emit the type
57// definition here.
58// CHECK: DICompositeType(tag: DW_TAG_structure_type, name: "e<int>"
59// CHECK-NOT: DIFlagFwdDecl
60// CHECK-SAME: ){{$}}
61
62template <typename T>
63struct f {
64  void g();
65};
66extern template class f<int>;
67template <typename T>
68void f<T>::g() {
69}
70f<int> fi;
71// CHECK: DICompositeType(tag: DW_TAG_structure_type, name: "f<int>"
72// CHECK-NOT: DIFlagFwdDecl
73// CHECK-SAME: ){{$}}
74
75template <typename T>
76struct g {
77  void f();
78};
79template <>
80void g<int>::f();
81extern template class g<int>;
82g<int> gi;
83// CHECK: DICompositeType(tag: DW_TAG_structure_type, name: "g<int>"
84// CHECK-NOT: DIFlagFwdDecl
85// CHECK-SAME: ){{$}}
86
87template <typename T>
88struct h {
89};
90template class h<int>;
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: DICompositeType(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: DICompositeType(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: !DICompositeType(tag: DW_TAG_structure_type, name: "k<int>"
117
118// CHECK: DICompositeType(tag: DW_TAG_structure_type, name: "b<int>"
119// CHECK-NOT: DIFlagFwdDecl
120// CHECK-SAME: ){{$}}
121