1 // RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -triple x86_64-apple-darwin %s -o - | FileCheck %s
3 // CHECK: @x ={{.*}} global %"struct.outer<foo>::inner" zeroinitializer, align 4, !dbg [[X:![0-9]+]]
6 template <int i
> int add(int j
) {
14 return MyClass().add
<2>(x
);
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
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]+]]
26 // CHECK: {{![0-9]+}} = distinct !DIGlobalVariable(
27 // CHECK-SAME: name: "var"
28 // CHECK-SAME: templateParams: {{![0-9]+}}
29 // CHECK: !DITemplateTypeParameter(name: "T", type: [[TY:![0-9]+]])
30 // CHECK: {{![0-9]+}} = distinct !DIGlobalVariable(
31 // CHECK-SAME: name: "var"
32 // CHECK-SAME: templateParams: {{![0-9]+}}
33 // CHECK: !DITemplateTypeParameter(name: "T", type: {{![0-9]+}})
34 // CHECK: {{![0-9]+}} = distinct !DIGlobalVariable(
35 // CHECK-SAME: name: "varray"
36 // CHECK-SAME: templateParams: {{![0-9]+}}
37 // CHECK: !DITemplateValueParameter(name: "N", type: [[TY]], value: i32 1)
39 // CHECK: ![[OUTER_FOO_INNER_ID:[0-9]*]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "inner"{{.*}}, identifier:
40 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "foo"
41 // CHECK-SAME: elements: [[FOO_MEM:![0-9]*]]
42 // CHECK-SAME: identifier: "_ZTS3foo"
43 // CHECK: [[FOO_MEM]] = !{[[FOO_FUNC:![0-9]*]]}
44 // CHECK: [[FOO_FUNC]] = !DISubprogram(name: "func", linkageName: "_ZN3foo4funcEN5outerIS_E5innerE",
45 // CHECK-SAME: type: [[FOO_FUNC_TYPE:![0-9]*]]
46 // CHECK: [[FOO_FUNC_TYPE]] = !DISubroutineType(types: [[FOO_FUNC_PARAMS:![0-9]*]])
47 // CHECK: [[FOO_FUNC_PARAMS]] = !{null, !{{[0-9]*}}, ![[OUTER_FOO_INNER_ID]]}
49 // CHECK: [[C:![0-9]*]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "MyClass"
50 // CHECK-SAME: elements: [[C_MEM:![0-9]*]]
51 // CHECK-SAME: vtableHolder: [[C]]
52 // CHECK-SAME: identifier: "_ZTS7MyClass")
53 // CHECK: [[C_MEM]] = !{[[C_VPTR:![0-9]*]], [[C_FUNC:![0-9]*]]}
54 // CHECK: [[C_VPTR]] = !DIDerivedType(tag: DW_TAG_member, name: "_vptr$MyClass"
56 // CHECK: [[C_FUNC]] = !DISubprogram(name: "func",{{.*}} line: 9,
58 // CHECK: !DISubprogram(name: "add<2>"
59 // CHECK-SAME: scope: [[C]]
61 // CHECK: [[VIRT_TEMP:![0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "virt<elem>"
62 // CHECK-SAME: elements: [[VIRT_MEM:![0-9]*]]
63 // CHECK-SAME: vtableHolder: [[VIRT_TEMP]]
64 // CHECK-SAME: templateParams: [[VIRT_TEMP_PARAM:![0-9]*]]
65 // CHECK-SAME: identifier: "_ZTS4virtI4elemE"
67 // CHECK: [[ELEM:![0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "elem"
68 // CHECK-SAME: elements: [[ELEM_MEM:![0-9]*]]
69 // CHECK-SAME: identifier: "_ZTS4elem"
70 // CHECK: [[ELEM_MEM]] = !{[[ELEM_X:![0-9]*]]}
71 // CHECK: [[ELEM_X]] = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: [[ELEM]]
72 // CHECK-SAME: baseType: [[VIRT_TEMP:![0-9]+]]
74 // CHECK: [[VIRT_TEMP_PARAM]] = !{[[VIRT_T:![0-9]*]]}
75 // CHECK: [[VIRT_T]] = !DITemplateTypeParameter(name: "T", type: [[ELEM]])
85 void func(outer
<foo
>::inner
);
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
103 static virt
<elem
> x
; // ensure that completing 'elem' will require/completing 'virt<elem>'
106 elem e
; // ensure 'elem' is required to be complete when it is emitted as a template argument for 'virt<elem>'
109 virt
<elem
> d
; // emit 'virt<elem>'
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]]
120 template <typename T
>
122 template <typename P
>
124 template <typename T
, int N
>
129 varray
<int, 1>[0] = 1;