| 1 |
// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -triple x86_64-apple-darwin %s -o - | FileCheck %s |
| 2 |
|
| 3 |
// CHECK: @x ={{.*}} global %"struct.outer<foo>::inner" zeroinitializer, align 4, !dbg [[X:![0-9]+]] |
| 4 |
|
| 5 |
struct MyClass { |
| 6 |
template <int i> int add(int j) { |
| 7 |
return i + j; |
| 8 |
} |
| 9 |
virtual void func() { |
| 10 |
} |
| 11 |
}; |
| 12 |
|
| 13 |
int add2(int x) { |
| 14 |
return MyClass().add<2>(x); |
| 15 |
} |
| 16 |
|
| 17 |
inline int add3(int x) { |
| 18 |
return MyClass().add<3>(x); // even though add<3> is ODR used, don't emit it since we don't codegen it |
| 19 |
} |
| 20 |
|
| 21 |
// The compile unit pulls in the global variables first. |
| 22 |
// CHECK: [[X]] = !DIGlobalVariableExpression(var: [[XV:.*]], expr: !DIExpression()) |
| 23 |
// CHECK: [[XV]] = distinct !DIGlobalVariable(name: "x", |
| 24 |
// CHECK-SAME: type: ![[OUTER_FOO_INNER_ID:[0-9]+]] |
| 25 |
|
| 26 |
// CHECK: [[C:![0-9]*]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "MyClass" |
| 27 |
// CHECK-SAME: elements: [[C_MEM:![0-9]*]] |
| 28 |
// CHECK-SAME: vtableHolder: [[C]] |
| 29 |
// CHECK-SAME: identifier: "_ZTS7MyClass") |
| 30 |
// CHECK: [[C_MEM]] = !{[[C_VPTR:![0-9]*]], [[C_FUNC:![0-9]*]]} |
| 31 |
// CHECK: [[C_VPTR]] = !DIDerivedType(tag: DW_TAG_member, name: "_vptr$MyClass" |
| 32 |
|
| 33 |
// CHECK: [[C_FUNC]] = !DISubprogram(name: "func",{{.*}} line: 9, |
| 34 |
|
| 35 |
// CHECK: [[VIRT_TEMP:![0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "virt<elem>" |
| 36 |
// CHECK-SAME: elements: [[VIRT_MEM:![0-9]*]] |
| 37 |
// CHECK-SAME: vtableHolder: [[VIRT_TEMP]] |
| 38 |
// CHECK-SAME: templateParams: [[VIRT_TEMP_PARAM:![0-9]*]] |
| 39 |
// CHECK-SAME: identifier: "_ZTS4virtI4elemE" |
| 40 |
|
| 41 |
// CHECK: [[ELEM:![0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "elem" |
| 42 |
// CHECK-SAME: elements: [[ELEM_MEM:![0-9]*]] |
| 43 |
// CHECK-SAME: identifier: "_ZTS4elem" |
| 44 |
// CHECK: [[ELEM_MEM]] = !{[[ELEM_X:![0-9]*]]} |
| 45 |
// CHECK: [[ELEM_X]] = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: [[ELEM]] |
| 46 |
// CHECK-SAME: baseType: [[VIRT_TEMP:![0-9]+]] |
| 47 |
|
| 48 |
// CHECK: [[VIRT_TEMP_PARAM]] = !{[[VIRT_T:![0-9]*]]} |
| 49 |
// CHECK: [[VIRT_T]] = !DITemplateTypeParameter(name: "T", type: [[ELEM]]) |
| 50 |
|
| 51 |
// CHECK: {{![0-9]+}} = distinct !DIGlobalVariable( |
| 52 |
// CHECK-SAME: name: "var" |
| 53 |
// CHECK-SAME: templateParams: {{![0-9]+}} |
| 54 |
// CHECK: !DITemplateTypeParameter(name: "T", type: [[TY:![0-9]+]]) |
| 55 |
// CHECK: {{![0-9]+}} = distinct !DIGlobalVariable( |
| 56 |
// CHECK-SAME: name: "var" |
| 57 |
// CHECK-SAME: templateParams: {{![0-9]+}} |
| 58 |
// CHECK: !DITemplateTypeParameter(name: "T", type: {{![0-9]+}}) |
| 59 |
// CHECK: {{![0-9]+}} = distinct !DIGlobalVariable( |
| 60 |
// CHECK-SAME: name: "varray" |
| 61 |
// CHECK-SAME: templateParams: {{![0-9]+}} |
| 62 |
// CHECK: !DITemplateValueParameter(name: "N", type: [[TY]], value: i32 1) |
| 63 |
|
| 64 |
// CHECK: ![[OUTER_FOO_INNER_ID:[0-9]*]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "inner"{{.*}}, identifier: |
| 65 |
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "foo" |
| 66 |
// CHECK-SAME: elements: [[FOO_MEM:![0-9]*]] |
| 67 |
// CHECK-SAME: identifier: "_ZTS3foo" |
| 68 |
// CHECK: [[FOO_MEM]] = !{[[FOO_FUNC:![0-9]*]]} |
| 69 |
// CHECK: [[FOO_FUNC]] = !DISubprogram(name: "func", linkageName: "_ZN3foo4funcEN5outerIS_E5innerE", |
| 70 |
// CHECK-SAME: type: [[FOO_FUNC_TYPE:![0-9]*]] |
| 71 |
// CHECK: [[FOO_FUNC_TYPE]] = !DISubroutineType(types: [[FOO_FUNC_PARAMS:![0-9]*]]) |
| 72 |
// CHECK: [[FOO_FUNC_PARAMS]] = !{null, !{{[0-9]*}}, ![[OUTER_FOO_INNER_ID]]} |
| 73 |
|
| 74 |
// CHECK: !DISubprogram(name: "add<2>" |
| 75 |
// CHECK-SAME: scope: [[C]] |
| 76 |
|
| 77 |
template<typename T> |
| 78 |
struct outer { |
| 79 |
struct inner { |
| 80 |
int i; |
| 81 |
}; |
| 82 |
}; |
| 83 |
|
| 84 |
struct foo { |
| 85 |
void func(outer<foo>::inner); |
| 86 |
}; |
| 87 |
|
| 88 |
inline void func() { |
| 89 |
// require 'foo' to be complete before the emission of 'inner' so that, when |
| 90 |
// constructing the context chain for 'x' we emit the full definition of |
| 91 |
// 'foo', which requires the definition of 'inner' again |
| 92 |
foo f; |
| 93 |
} |
| 94 |
|
| 95 |
outer<foo>::inner x; |
| 96 |
|
| 97 |
template <typename T> |
| 98 |
struct virt { |
| 99 |
T* values; |
| 100 |
virtual ~virt(); |
| 101 |
}; |
| 102 |
struct elem { |
| 103 |
static virt<elem> x; // ensure that completing 'elem' will require/completing 'virt<elem>' |
| 104 |
}; |
| 105 |
inline void f1() { |
| 106 |
elem e; // ensure 'elem' is required to be complete when it is emitted as a template argument for 'virt<elem>' |
| 107 |
}; |
| 108 |
void f2() { |
| 109 |
virt<elem> d; // emit 'virt<elem>' |
| 110 |
} |
| 111 |
|
| 112 |
// Check that the member function template specialization and implicit special |
| 113 |
// members (the default ctor) refer to their class by scope, even though they |
| 114 |
// didn't appear in the class's member list (C_MEM). This prevents the functions |
| 115 |
// from being added to type units, while still appearing in the type |
| 116 |
// declaration/reference in the compile unit. |
| 117 |
// CHECK: !DISubprogram(name: "MyClass" |
| 118 |
// CHECK-SAME: scope: [[C]] |
| 119 |
|
| 120 |
template <typename T> |
| 121 |
T var = T(); |
| 122 |
template <typename P> |
| 123 |
P var<P *> = P(); |
| 124 |
template <typename T, int N> |
| 125 |
T varray[N]; |
| 126 |
void f3() { |
| 127 |
var<int> = 1; |
| 128 |
var<int *> = 1; |
| 129 |
varray<int, 1>[0] = 1; |
| 130 |
} |