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 15 template <typename T> 16 struct a { 17 }; 18 extern template class a<int>; 19 // CHECK-NOT: DICompositeType(tag: DW_TAG_structure_type, name: "a<int>" 20 21 template <typename T> 22 struct b { 23 }; 24 extern template class b<int>; 25 b<int> bi; 26 27 template <typename T> 28 struct c { 29 void f() {} 30 }; 31 extern template class c<int>; 32 c<int> ci; 33 // CHECK: DICompositeType(tag: DW_TAG_structure_type, name: "c<int>" 34 // CHECK-SAME: DIFlagFwdDecl 35 36 template <typename T> 37 struct d { 38 void f(); 39 }; 40 extern template class d<int>; 41 d<int> di; 42 // CHECK: DICompositeType(tag: DW_TAG_structure_type, name: "d<int>" 43 // CHECK-NOT: DIFlagFwdDecl 44 // CHECK-SAME: ){{$}} 45 46 template <typename T> 47 struct e { 48 void f(); 49 }; 50 template <typename T> 51 void e<T>::f() { 52 } 53 extern template class e<int>; 54 e<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 62 template <typename T> 63 struct f { 64 void g(); 65 }; 66 extern template class f<int>; 67 template <typename T> 68 void f<T>::g() { 69 } 70 f<int> fi; 71 // CHECK: DICompositeType(tag: DW_TAG_structure_type, name: "f<int>" 72 // CHECK-NOT: DIFlagFwdDecl 73 // CHECK-SAME: ){{$}} 74 75 template <typename T> 76 struct g { 77 void f(); 78 }; 79 template <> 80 void g<int>::f(); 81 extern template class g<int>; 82 g<int> gi; 83 // CHECK: DICompositeType(tag: DW_TAG_structure_type, name: "g<int>" 84 // CHECK-NOT: DIFlagFwdDecl 85 // CHECK-SAME: ){{$}} 86 87 template <typename T> 88 struct h { 89 }; 90 template class h<int>; 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 template <typename T> 109 struct j_wrap { 110 }; 111 j_wrap<j<int>> j_wrap_j; 112 // CHECK: DICompositeType(tag: DW_TAG_structure_type, name: "j<int, int>" 113 // CHECK: DICompositeType(tag: DW_TAG_structure_type, name: "j_wrap<j<int, int> >" 114 115 template <typename T> 116 struct k { 117 }; 118 template <> 119 struct k<int>; 120 template struct k<int>; 121 // CHECK-NOT: !DICompositeType(tag: DW_TAG_structure_type, name: "k<int>" 122 123 // CHECK: DICompositeType(tag: DW_TAG_structure_type, name: "b<int>" 124 // CHECK-NOT: DIFlagFwdDecl 125 // CHECK-SAME: ){{$}} 126