1 // Test without serialization:
2 // RUN: %clang_cc1 -std=c++11 -triple x86_64-linux-gnu -fms-extensions \
3 // RUN: -ast-dump -ast-dump-filter Test %s \
4 // RUN: | FileCheck --strict-whitespace %s
6 // Test with serialization: FIXME: Find why the outputs differs and fix it!
7 // : %clang_cc1 -std=c++11 -triple x86_64-linux-gnu -fms-extensions -emit-pch -o %t %s
8 // : %clang_cc1 -x c++ -std=c++11 -triple x86_64-linux-gnu -fms-extensions -include-pch %t \
9 // : -ast-dump-all -ast-dump-filter Test /dev/null \
10 // : | sed -e "s/ <undeserialized declarations>//" -e "s/ imported//" \
11 // : | FileCheck --strict-whitespace %s
14 enum class TestEnumDeclScoped
;
15 enum TestEnumDeclFixed
: int;
17 // CHECK: EnumDecl{{.*}} class TestEnumDeclScoped 'int'
18 // CHECK: EnumDecl{{.*}} TestEnumDeclFixed 'int'
21 int TestFieldDeclInit
= 0;
23 // CHECK: FieldDecl{{.*}} TestFieldDeclInit 'int'
24 // CHECK-NEXT: IntegerLiteral
26 namespace testVarDeclNRVO
{
30 return TestVarDeclNRVO
;
33 // CHECK: FunctionDecl{{.*}} TestFuncNRVO 'A ()'
34 // CHECK-NEXT: `-CompoundStmt
35 // CHECK-NEXT: |-DeclStmt
36 // CHECK-NEXT: | `-VarDecl{{.*}} TestVarDeclNRVO 'A':'testVarDeclNRVO::A' nrvo callinit
37 // CHECK-NEXT: | `-CXXConstructExpr
38 // CHECK-NEXT: `-ReturnStmt{{.*}} nrvo_candidate(Var {{.*}} 'TestVarDeclNRVO' 'A':'testVarDeclNRVO::A')
40 void testParmVarDeclInit(int TestParmVarDeclInit
= 0);
41 // CHECK: ParmVarDecl{{.*}} TestParmVarDeclInit 'int'
42 // CHECK-NEXT: IntegerLiteral{{.*}}
44 namespace TestNamespaceDecl
{
47 // CHECK: NamespaceDecl{{.*}} TestNamespaceDecl
48 // CHECK-NEXT: VarDecl
50 namespace TestNamespaceDecl
{
53 // CHECK: NamespaceDecl{{.*}} TestNamespaceDecl
54 // CHECK-NEXT: original Namespace
55 // CHECK-NEXT: VarDecl
57 inline namespace TestNamespaceDeclInline
{
59 // CHECK: NamespaceDecl{{.*}} TestNamespaceDeclInline inline
61 namespace TestNestedNameSpace::Nested
{
63 // CHECK: NamespaceDecl{{.*}} TestNestedNameSpace
64 // CHECK: NamespaceDecl{{.*}} Nested nested{{\s*$}}
66 namespace TestMultipleNested::SecondLevelNested::Nested
{
68 // CHECK: NamespaceDecl{{.*}} TestMultipleNested
69 // CHECK: NamespaceDecl{{.*}} SecondLevelNested nested
70 // CHECK: NamespaceDecl{{.*}} Nested nested{{\s*$}}
72 namespace TestInlineNested::inline SecondLevel::inline Nested
{
74 // CHECK: NamespaceDecl{{.*}} TestInlineNested
75 // CHECK: NamespaceDecl{{.*}} SecondLevel inline nested
76 // CHECK: NamespaceDecl{{.*}} Nested inline nested{{\s*$}}
78 namespace testUsingDirectiveDecl
{
82 namespace TestUsingDirectiveDecl
{
83 using namespace testUsingDirectiveDecl::A
;
85 // CHECK: NamespaceDecl{{.*}} TestUsingDirectiveDecl
86 // CHECK-NEXT: UsingDirectiveDecl{{.*}} Namespace{{.*}} 'A'
88 namespace testNamespaceAlias
{
92 namespace TestNamespaceAlias
= testNamespaceAlias::A
;
93 // CHECK: NamespaceAliasDecl{{.*}} TestNamespaceAlias
94 // CHECK-NEXT: Namespace{{.*}} 'A'
96 using TestTypeAliasDecl
= int;
97 // CHECK: TypeAliasDecl{{.*}} TestTypeAliasDecl 'int'
99 namespace testTypeAliasTemplateDecl
{
100 template<typename T
> class A
;
101 template<typename T
> using TestTypeAliasTemplateDecl
= A
<T
>;
103 // CHECK: TypeAliasTemplateDecl{{.*}} TestTypeAliasTemplateDecl
104 // CHECK-NEXT: TemplateTypeParmDecl
105 // CHECK-NEXT: TypeAliasDecl{{.*}} TestTypeAliasTemplateDecl 'A<T>'
107 namespace testCXXRecordDecl
{
109 // CHECK: CXXRecordDecl{{.*}} class TestEmpty
110 // CHECK-NEXT: DefinitionData pass_in_registers empty aggregate standard_layout trivially_copyable pod trivial literal has_constexpr_non_copy_move_ctor can_const_default_init
111 // CHECK-NEXT: DefaultConstructor exists trivial constexpr
112 // CHECK-NEXT: CopyConstructor simple trivial has_const_param
113 // CHECK-NEXT: MoveConstructor exists simple trivial
114 // CHECK-NEXT: CopyAssignment simple trivial has_const_param
115 // CHECK-NEXT: MoveAssignment exists simple trivial
116 // CHECK-NEXT: Destructor simple irrelevant trivial
120 class TestCXXRecordDecl
: virtual A
, public B
{
124 // CHECK: CXXRecordDecl{{.*}} class TestCXXRecordDecl
125 // CHECK-NEXT: DefinitionData{{$}}
126 // CHECK-NEXT: DefaultConstructor exists non_trivial
127 // CHECK-NEXT: CopyConstructor simple non_trivial has_const_param
128 // CHECK-NEXT: MoveConstructor exists simple non_trivial
129 // CHECK-NEXT: CopyAssignment simple non_trivial has_const_param
130 // CHECK-NEXT: MoveAssignment exists simple non_trivial
131 // CHECK-NEXT: Destructor simple irrelevant trivial
132 // CHECK-NEXT: virtual private 'A':'testCXXRecordDecl::A'
133 // CHECK-NEXT: public 'B':'testCXXRecordDecl::B'
134 // CHECK-NEXT: CXXRecordDecl{{.*}} class TestCXXRecordDecl
135 // CHECK-NEXT: FieldDecl
138 class TestCXXRecordDeclPack
: public T
... {
140 // CHECK: CXXRecordDecl{{.*}} class TestCXXRecordDeclPack
141 // CHECK: public 'T'...
142 // CHECK-NEXT: CXXRecordDecl{{.*}} class TestCXXRecordDeclPack
144 thread_local
int TestThreadLocalInt
;
145 // CHECK: TestThreadLocalInt {{.*}} tls_dynamic
147 class testCXXMethodDecl
{
148 virtual void TestCXXMethodDeclPure() = 0;
149 void TestCXXMethodDeclDelete() = delete;
150 void TestCXXMethodDeclThrow() throw();
151 void TestCXXMethodDeclThrowType() throw(int);
153 // CHECK: CXXMethodDecl{{.*}} TestCXXMethodDeclPure 'void ()' virtual pure
154 // CHECK: CXXMethodDecl{{.*}} TestCXXMethodDeclDelete 'void ()' delete
155 // CHECK: CXXMethodDecl{{.*}} TestCXXMethodDeclThrow 'void () throw()'
156 // CHECK: CXXMethodDecl{{.*}} TestCXXMethodDeclThrowType 'void () throw(int)'
158 namespace testCXXConstructorDecl
{
160 class TestCXXConstructorDecl
: public A
{
162 TestCXXConstructorDecl(A
&a
, int i
) : A(a
), I(i
) { }
163 TestCXXConstructorDecl(A
&a
) : TestCXXConstructorDecl(a
, 0) { }
166 // CHECK: CXXConstructorDecl{{.*}} TestCXXConstructorDecl 'void {{.*}}'
167 // CHECK-NEXT: ParmVarDecl{{.*}} a
168 // CHECK-NEXT: ParmVarDecl{{.*}} i
169 // CHECK-NEXT: CXXCtorInitializer{{.*}}A
171 // CHECK: CXXCtorInitializer{{.*}}I
173 // CHECK: CompoundStmt
174 // CHECK: CXXConstructorDecl{{.*}} TestCXXConstructorDecl 'void {{.*}}'
175 // CHECK-NEXT: ParmVarDecl{{.*}} a
176 // CHECK-NEXT: CXXCtorInitializer{{.*}}TestCXXConstructorDecl
177 // CHECK-NEXT: CXXConstructExpr{{.*}}TestCXXConstructorDecl
179 class TestCXXDestructorDecl
{
180 ~TestCXXDestructorDecl() { }
182 // CHECK: CXXDestructorDecl{{.*}} ~TestCXXDestructorDecl 'void () noexcept'
183 // CHECK-NEXT: CompoundStmt
185 // Test that the range of a defaulted members is computed correctly.
186 class TestMemberRanges
{
188 TestMemberRanges() = default;
189 TestMemberRanges(const TestMemberRanges
&Other
) = default;
190 TestMemberRanges(TestMemberRanges
&&Other
) = default;
191 ~TestMemberRanges() = default;
192 TestMemberRanges
&operator=(const TestMemberRanges
&Other
) = default;
193 TestMemberRanges
&operator=(TestMemberRanges
&&Other
) = default;
195 void SomeFunction() {
197 TestMemberRanges
B(A
);
199 A
= static_cast<TestMemberRanges
&&>(B
);
200 TestMemberRanges
C(static_cast<TestMemberRanges
&&>(A
));
202 // CHECK: CXXConstructorDecl{{.*}} <line:{{.*}}:3, col:30>
203 // CHECK: CXXConstructorDecl{{.*}} <line:{{.*}}:3, col:59>
204 // CHECK: CXXConstructorDecl{{.*}} <line:{{.*}}:3, col:54>
205 // CHECK: CXXDestructorDecl{{.*}} <line:{{.*}}:3, col:31>
206 // CHECK: CXXMethodDecl{{.*}} <line:{{.*}}:3, col:70>
207 // CHECK: CXXMethodDecl{{.*}} <line:{{.*}}:3, col:65>
209 class TestCXXConversionDecl
{
210 operator int() { return 0; }
212 // CHECK: CXXConversionDecl{{.*}} operator int 'int ()'
213 // CHECK-NEXT: CompoundStmt
215 namespace TestStaticAssertDecl
{
216 static_assert(true, "msg");
218 // CHECK: NamespaceDecl{{.*}} TestStaticAssertDecl
219 // CHECK-NEXT: StaticAssertDecl{{.*> .*$}}
220 // CHECK-NEXT: CXXBoolLiteralExpr
221 // CHECK-NEXT: StringLiteral
223 namespace testFunctionTemplateDecl
{
228 template<typename T
> void TestFunctionTemplate(T
) { }
230 // implicit instantiation
231 void bar(A a
) { TestFunctionTemplate(a
); }
233 // explicit specialization
234 template<> void TestFunctionTemplate(B
);
236 // explicit instantiation declaration
237 extern template void TestFunctionTemplate(C
);
239 // explicit instantiation definition
240 template void TestFunctionTemplate(D
);
242 // CHECK: FunctionTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-14]]:3, col:55> col:29 TestFunctionTemplate
243 // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <col:12, col:21> col:21 referenced typename depth 0 index 0 T
244 // CHECK-NEXT: |-FunctionDecl 0x{{.+}} <col:24, col:55> col:29 TestFunctionTemplate 'void (T)'
245 // CHECK-NEXT: | |-ParmVarDecl 0x{{.+}} <col:50> col:51 'T'
246 // CHECK-NEXT: | `-CompoundStmt 0x{{.+}} <col:53, col:55>
247 // CHECK-NEXT: |-FunctionDecl 0x{{.+}} <col:24, col:55> col:29 used TestFunctionTemplate 'void (testFunctionTemplateDecl::A)'
248 // CHECK-NEXT: | |-TemplateArgument type 'testFunctionTemplateDecl::A'
249 // CHECK-NEXT: | | `-RecordType 0{{.+}} 'testFunctionTemplateDecl::A'
250 // CHECK-NEXT: | | `-CXXRecord 0x{{.+}} 'A'
251 // CHECK-NEXT: | |-ParmVarDecl 0x{{.+}} <col:50> col:51 'testFunctionTemplateDecl::A'
252 // CHECK-NEXT: | `-CompoundStmt 0x{{.+}} <col:53, col:55>
253 // CHECK-NEXT: |-Function 0x{{.+}} 'TestFunctionTemplate' 'void (B)'
254 // CHECK-NEXT: |-FunctionDecl 0x{{.+}} <col:24, col:55> col:29 TestFunctionTemplate 'void (testFunctionTemplateDecl::C)'
255 // CHECK-NEXT: | |-TemplateArgument type 'testFunctionTemplateDecl::C'
256 // CHECK-NEXT: | | `-RecordType 0{{.+}} 'testFunctionTemplateDecl::C'
257 // CHECK-NEXT: | | `-CXXRecord 0x{{.+}} 'C'
258 // CHECK-NEXT: | `-ParmVarDecl 0x{{.+}} <col:50> col:51 'testFunctionTemplateDecl::C'
259 // CHECK-NEXT: `-FunctionDecl 0x{{.+}} <col:24, col:55> col:29 TestFunctionTemplate 'void (testFunctionTemplateDecl::D)'
260 // CHECK-NEXT: |-TemplateArgument type 'testFunctionTemplateDecl::D'
261 // CHECK-NEXT: | `-RecordType 0{{.+}} 'testFunctionTemplateDecl::D'
262 // CHECK-NEXT: | `-CXXRecord 0x{{.+}} 'D'
263 // CHECK-NEXT: |-ParmVarDecl 0x{{.+}} <col:50> col:51 'testFunctionTemplateDecl::D'
264 // CHECK-NEXT: `-CompoundStmt 0x{{.+}} <col:53, col:55>
266 // CHECK: FunctionDecl 0x{{.+}} prev 0x{{.+}} <{{.+}}:[[@LINE-32]]:3, col:41> col:19 TestFunctionTemplate 'void (B)'
267 // CHECK-NEXT: |-TemplateArgument type 'testFunctionTemplateDecl::B'
268 // CHECK-NEXT: | `-RecordType 0{{.+}} 'testFunctionTemplateDecl::B'
269 // CHECK-NEXT: | `-CXXRecord 0x{{.+}} 'B'
270 // CHECK-NEXT: `-ParmVarDecl 0x{{.+}} <col:40> col:41 'B':'testFunctionTemplateDecl::B'
273 namespace testClassTemplateDecl
{
279 template<typename T
> class TestClassTemplate
{
282 ~TestClassTemplate();
287 // implicit instantiation
288 TestClassTemplate
<A
> a
;
290 // explicit specialization
291 template<> class TestClassTemplate
<B
> {
295 // explicit instantiation declaration
296 extern template class TestClassTemplate
<C
>;
298 // explicit instantiation definition
299 template class TestClassTemplate
<D
>;
301 // partial explicit specialization
302 template<typename T1
, typename T2
> class TestClassTemplatePartial
{
305 template<typename T1
> class TestClassTemplatePartial
<T1
, A
> {
309 template<typename T
= int> struct TestTemplateDefaultType
;
310 template<typename T
> struct TestTemplateDefaultType
{ };
312 template<int I
= 42> struct TestTemplateDefaultNonType
;
313 template<int I
> struct TestTemplateDefaultNonType
{ };
315 template<template<typename
> class TT
= TestClassTemplate
> struct TestTemplateTemplateDefaultType
;
316 template<template<typename
> class TT
> struct TestTemplateTemplateDefaultType
{ };
319 // CHECK: ClassTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-40]]:3, line:[[@LINE-34]]:3> line:[[@LINE-40]]:30 TestClassTemplate{{$}}
320 // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <col:12, col:21> col:21 typename depth 0 index 0 T{{$}}
321 // CHECK-NEXT: |-CXXRecordDecl 0x{{.+}} <col:24, line:[[@LINE-36]]:3> line:[[@LINE-42]]:30 class TestClassTemplate definition{{$}}
322 // CHECK-NEXT: | |-DefinitionData standard_layout has_user_declared_ctor can_const_default_init{{$}}
323 // CHECK-NEXT: | | |-DefaultConstructor exists non_trivial user_provided{{$}}
324 // CHECK-NEXT: | | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param{{$}}
325 // CHECK-NEXT: | | |-MoveConstructor{{$}}
326 // CHECK-NEXT: | | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param{{$}}
327 // CHECK-NEXT: | | |-MoveAssignment{{$}}
328 // CHECK-NEXT: | | `-Destructor irrelevant non_trivial user_declared{{$}}
329 // CHECK-NEXT: | |-CXXRecordDecl 0x{{.+}} <col:24, col:30> col:30 implicit referenced class TestClassTemplate{{$}}
330 // CHECK-NEXT: | |-AccessSpecDecl 0x{{.+}} <line:[[@LINE-50]]:3, col:9> col:3 public{{$}}
331 // CHECK-NEXT: | |-CXXConstructorDecl 0x{{.+}} <line:[[@LINE-50]]:5, col:23> col:5 TestClassTemplate<T> 'void ()'{{$}}
332 // CHECK-NEXT: | |-CXXDestructorDecl 0x{{.+}} <line:[[@LINE-50]]:5, col:24> col:5 ~TestClassTemplate<T> 'void ()' not_selected{{$}}
333 // CHECK-NEXT: | |-CXXMethodDecl 0x{{.+}} <line:[[@LINE-50]]:5, col:11> col:9 j 'int ()'{{$}}
334 // CHECK-NEXT: | `-FieldDecl 0x{{.+}} <line:[[@LINE-50]]:5, col:9> col:9 i 'int'{{$}}
335 // CHECK-NEXT: |-ClassTemplateSpecializationDecl 0x{{.+}} <line:[[@LINE-56]]:3, line:[[@LINE-50]]:3> line:[[@LINE-56]]:30 class TestClassTemplate definition implicit_instantiation{{$}}
336 // CHECK-NEXT: | |-DefinitionData standard_layout has_user_declared_ctor can_const_default_init{{$}}
337 // CHECK-NEXT: | | |-DefaultConstructor exists non_trivial user_provided{{$}}
338 // CHECK-NEXT: | | |-CopyConstructor simple trivial has_const_param implicit_has_const_param{{$}}
339 // CHECK-NEXT: | | |-MoveConstructor{{$}}
340 // CHECK-NEXT: | | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param{{$}}
341 // CHECK-NEXT: | | |-MoveAssignment{{$}}
342 // CHECK-NEXT: | | `-Destructor non_trivial user_declared{{$}}
343 // CHECK-NEXT: | |-TemplateArgument type 'testClassTemplateDecl::A'{{$}}
344 // CHECK-NEXT: | | `-RecordType 0{{.+}} 'testClassTemplateDecl::A'{{$}}
345 // CHECK-NEXT: | | `-CXXRecord 0x{{.+}} 'A'{{$}}
346 // CHECK-NEXT: | |-CXXRecordDecl 0x{{.+}} <col:24, col:30> col:30 implicit class TestClassTemplate{{$}}
347 // CHECK-NEXT: | |-AccessSpecDecl 0x{{.+}} <line:[[@LINE-67]]:3, col:9> col:3 public{{$}}
348 // CHECK-NEXT: | |-CXXConstructorDecl 0x{{.+}} <line:[[@LINE-67]]:5, col:23> col:5 used TestClassTemplate 'void ()' implicit_instantiation instantiated_from {{0x[^ ]+}}{{$}}
349 // CHECK-NEXT: | |-CXXDestructorDecl 0x{{.+}} <line:[[@LINE-67]]:5, col:24> col:5 used ~TestClassTemplate 'void () noexcept' implicit_instantiation instantiated_from {{0x[^ ]+}}{{$}}
350 // CHECK-NEXT: | |-CXXMethodDecl 0x{{.+}} <line:[[@LINE-67]]:5, col:11> col:9 j 'int ()' implicit_instantiation instantiated_from {{0x[^ ]+}}{{$}}
351 // CHECK-NEXT: | |-FieldDecl 0x{{.+}} <line:[[@LINE-67]]:5, col:9> col:9 i 'int'{{$}}
352 // CHECK-NEXT: | `-CXXConstructorDecl 0x{{.+}} <line:[[@LINE-73]]:30> col:30 implicit constexpr TestClassTemplate 'void (const TestClassTemplate<A> &)' inline default trivial noexcept-unevaluated 0x{{.+}}{{$}}
353 // CHECK-NEXT: | `-ParmVarDecl 0x{{.+}} <col:30> col:30 'const TestClassTemplate<A> &'{{$}}
354 // CHECK-NEXT: |-ClassTemplateSpecialization 0x{{.+}} 'TestClassTemplate'{{$}}
355 // CHECK-NEXT: |-ClassTemplateSpecialization 0x{{.+}} 'TestClassTemplate'{{$}}
356 // CHECK-NEXT: `-ClassTemplateSpecialization 0x{{.+}} 'TestClassTemplate'{{$}}
358 // CHECK: ClassTemplateSpecializationDecl 0x{{.+}} <{{.+}}:[[@LINE-67]]:3, line:[[@LINE-65]]:3> line:[[@LINE-67]]:20 class TestClassTemplate definition explicit_specialization{{$}}
359 // CHECK-NEXT: |-DefinitionData pass_in_registers standard_layout trivially_copyable trivial literal{{$}}
360 // CHECK-NEXT: | |-DefaultConstructor exists trivial needs_implicit{{$}}
361 // CHECK-NEXT: | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param{{$}}
362 // CHECK-NEXT: | |-MoveConstructor exists simple trivial needs_implicit{{$}}
363 // CHECK-NEXT: | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param{{$}}
364 // CHECK-NEXT: | |-MoveAssignment exists simple trivial needs_implicit{{$}}
365 // CHECK-NEXT: | `-Destructor simple irrelevant trivial needs_implicit{{$}}
366 // CHECK-NEXT: |-TemplateArgument type 'testClassTemplateDecl::B'{{$}}
367 // CHECK-NEXT: | `-RecordType 0{{.+}} 'testClassTemplateDecl::B'{{$}}
368 // CHECK-NEXT: | `-CXXRecord 0x{{.+}} 'B'{{$}}
369 // CHECK-NEXT: |-CXXRecordDecl 0x{{.+}} <col:14, col:20> col:20 implicit class TestClassTemplate{{$}}
370 // CHECK-NEXT: `-FieldDecl 0x{{.+}} <line:[[@LINE-78]]:5, col:9> col:9 j 'int'{{$}}
372 // CHECK: ClassTemplateSpecializationDecl 0x{{.+}} <{{.+}}:{{.*}}:3, col:44> col:25 class TestClassTemplate definition explicit_instantiation_declaration{{$}}
373 // CHECK-NEXT: |-DefinitionData standard_layout has_user_declared_ctor can_const_default_init{{$}}
374 // CHECK-NEXT: | |-DefaultConstructor exists non_trivial user_provided{{$}}
375 // CHECK-NEXT: | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param{{$}}
376 // CHECK-NEXT: | |-MoveConstructor{{$}}
377 // CHECK-NEXT: | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param{{$}}
378 // CHECK-NEXT: | |-MoveAssignment{{$}}
379 // CHECK-NEXT: | `-Destructor non_trivial user_declared{{$}}
380 // CHECK-NEXT: |-TemplateArgument type 'testClassTemplateDecl::C'{{$}}
381 // CHECK-NEXT: | `-RecordType 0{{.+}} 'testClassTemplateDecl::C'{{$}}
382 // CHECK-NEXT: | `-CXXRecord 0x{{.+}} 'C'{{$}}
383 // CHECK-NEXT: |-CXXRecordDecl 0x{{.+}} <line:[[@LINE-104]]:24, col:30> col:30 implicit class TestClassTemplate{{$}}
384 // CHECK-NEXT: |-AccessSpecDecl 0x{{.+}} <line:[[@LINE-104]]:3, col:9> col:3 public{{$}}
385 // CHECK-NEXT: |-CXXConstructorDecl 0x{{.+}} <line:[[@LINE-104]]:5, col:23> col:5 TestClassTemplate 'void ()' explicit_instantiation_declaration instantiated_from {{0x[^ ]+}}{{$}}
386 // CHECK-NEXT: |-CXXDestructorDecl 0x{{.+}} <line:[[@LINE-104]]:5, col:24> col:5 ~TestClassTemplate 'void ()' explicit_instantiation_declaration noexcept-unevaluated 0x{{[^ ]+}} instantiated_from {{0x[^ ]+}}
387 // CHECK-NEXT: |-CXXMethodDecl 0x{{.+}} <line:[[@LINE-104]]:5, col:11> col:9 j 'int ()' explicit_instantiation_declaration instantiated_from {{0x[^ ]+}}{{$}}
388 // CHECK-NEXT: `-FieldDecl 0x{{.+}} <line:[[@LINE-104]]:5, col:9> col:9 i 'int'{{$}}
390 // CHECK: ClassTemplateSpecializationDecl 0x{{.+}} <{{.+}}:[[@LINE-91]]:3, col:37> col:18 class TestClassTemplate definition explicit_instantiation_definition{{$}}
391 // CHECK-NEXT: |-DefinitionData standard_layout has_user_declared_ctor can_const_default_init{{$}}
392 // CHECK-NEXT: | |-DefaultConstructor exists non_trivial user_provided{{$}}
393 // CHECK-NEXT: | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param{{$}}
394 // CHECK-NEXT: | |-MoveConstructor{{$}}
395 // CHECK-NEXT: | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param{{$}}
396 // CHECK-NEXT: | |-MoveAssignment{{$}}
397 // CHECK-NEXT: | `-Destructor non_trivial user_declared{{$}}
398 // CHECK-NEXT: |-TemplateArgument type 'testClassTemplateDecl::D'{{$}}
399 // CHECK-NEXT: | `-RecordType 0{{.+}} 'testClassTemplateDecl::D'{{$}}
400 // CHECK-NEXT: | `-CXXRecord 0x{{.+}} 'D'{{$}}
401 // CHECK-NEXT: |-CXXRecordDecl 0x{{.+}} <line:[[@LINE-122]]:24, col:30> col:30 implicit class TestClassTemplate{{$}}
402 // CHECK-NEXT: |-AccessSpecDecl 0x{{.+}} <line:[[@LINE-122]]:3, col:9> col:3 public{{$}}
403 // CHECK-NEXT: |-CXXConstructorDecl 0x{{.+}} <line:[[@LINE-122]]:5, col:23> col:5 TestClassTemplate 'void ()' implicit_instantiation instantiated_from {{0x[^ ]+}}{{$}}
404 // CHECK-NEXT: |-CXXDestructorDecl 0x{{.+}} <line:[[@LINE-122]]:5, col:24> col:5 ~TestClassTemplate 'void ()' implicit_instantiation noexcept-unevaluated 0x{{.+}} instantiated_from {{0x[^ ]+}}{{$}}
405 // CHECK-NEXT: |-CXXMethodDecl 0x{{.+}} <line:[[@LINE-122]]:5, col:11> col:9 j 'int ()' implicit_instantiation instantiated_from {{0x[^ ]+}}{{$}}
406 // CHECK-NEXT: `-FieldDecl 0x{{.+}} <line:[[@LINE-122]]:5, col:9> col:9 i 'int'{{$}}
408 // CHECK: ClassTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-106]]:3, line:[[@LINE-104]]:3> line:[[@LINE-106]]:44 TestClassTemplatePartial{{$}}
409 // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <col:12, col:21> col:21 typename depth 0 index 0 T1{{$}}
410 // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <col:25, col:34> col:34 typename depth 0 index 1 T2{{$}}
411 // CHECK-NEXT: `-CXXRecordDecl 0x{{.+}} <col:38, line:[[@LINE-107]]:3> line:[[@LINE-109]]:44 class TestClassTemplatePartial definition{{$}}
412 // CHECK-NEXT: |-DefinitionData standard_layout trivially_copyable trivial literal{{$}}
413 // CHECK-NEXT: | |-DefaultConstructor exists trivial needs_implicit{{$}}
414 // CHECK-NEXT: | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param{{$}}
415 // CHECK-NEXT: | |-MoveConstructor exists simple trivial needs_implicit{{$}}
416 // CHECK-NEXT: | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param{{$}}
417 // CHECK-NEXT: | |-MoveAssignment exists simple trivial needs_implicit{{$}}
418 // CHECK-NEXT: | `-Destructor simple irrelevant trivial needs_implicit{{$}}
419 // CHECK-NEXT: |-CXXRecordDecl 0x{{.+}} <col:38, col:44> col:44 implicit class TestClassTemplatePartial{{$}}
420 // CHECK-NEXT: `-FieldDecl 0x{{.+}} <line:[[@LINE-117]]:5, col:9> col:9 i 'int'{{$}}
422 // CHECK: ClassTemplatePartialSpecializationDecl 0x{{.+}} <{{.+}}:[[@LINE-117]]:3, line:[[@LINE-115]]:3> line:[[@LINE-117]]:31 class TestClassTemplatePartial definition explicit_specialization{{$}}
423 // CHECK-NEXT: |-DefinitionData standard_layout trivially_copyable trivial literal{{$}}
424 // CHECK-NEXT: | |-DefaultConstructor exists trivial needs_implicit{{$}}
425 // CHECK-NEXT: | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param{{$}}
426 // CHECK-NEXT: | |-MoveConstructor exists simple trivial needs_implicit{{$}}
427 // CHECK-NEXT: | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param{{$}}
428 // CHECK-NEXT: | |-MoveAssignment exists simple trivial needs_implicit{{$}}
429 // CHECK-NEXT: | `-Destructor simple irrelevant trivial needs_implicit{{$}}
430 // CHECK-NEXT: |-TemplateArgument type 'type-parameter-0-0'{{$}}
431 // CHECK-NEXT: | `-TemplateTypeParmType 0x{{.+}} 'type-parameter-0-0' dependent depth 0 index 0{{$}}
432 // CHECK-NEXT: |-TemplateArgument type 'testClassTemplateDecl::A'{{$}}
433 // CHECK-NEXT: | `-RecordType 0x{{.+}} 'testClassTemplateDecl::A'{{$}}
434 // CHECK-NEXT: | `-CXXRecord 0x{{.+}} 'A'{{$}}
435 // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <col:12, col:21> col:21 referenced typename depth 0 index 0 T1{{$}}
436 // CHECK-NEXT: |-CXXRecordDecl 0x{{.+}} <col:25, col:31> col:31 implicit class TestClassTemplatePartial{{$}}
437 // CHECK-NEXT: `-FieldDecl 0x{{.+}} <line:[[@LINE-131]]:5, col:9> col:9 j 'int'{{$}}
439 // CHECK: ClassTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-130]]:3, col:37> col:37 TestTemplateDefaultType{{$}}
440 // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <col:12, col:25> col:21 typename depth 0 index 0 T{{$}}
441 // CHECK-NEXT: | `-TemplateArgument type 'int'{{$}}
442 // CHECK-NEXT: | `-BuiltinType 0x{{.+}} 'int'{{$}}
443 // CHECK-NEXT: `-CXXRecordDecl 0x{{.+}} <col:30, col:37> col:37 struct TestTemplateDefaultType{{$}}
445 // CHECK: ClassTemplateDecl 0x{{.+}} prev 0x{{.+}} <{{.+}}:[[@LINE-135]]:3, col:57> col:31 TestTemplateDefaultType{{$}}
446 // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <col:12, col:21> col:21 typename depth 0 index 0 T{{$}}
447 // CHECK-NEXT: | `-TemplateArgument type 'int'{{$}}
448 // CHECK-NEXT: | |-inherited from TemplateTypeParm 0x{{.+}} 'T'{{$}}
449 // CHECK-NEXT: | `-BuiltinType 0x{{.+}} 'int'{{$}}
450 // CHECK-NEXT: `-CXXRecordDecl 0x{{.+}} prev 0x{{.+}} <col:24, col:57> col:31 struct TestTemplateDefaultType definition{{$}}
451 // CHECK-NEXT: |-DefinitionData empty aggregate standard_layout trivially_copyable pod trivial literal has_constexpr_non_copy_move_ctor can_const_default_init{{$}}
452 // CHECK-NEXT: | |-DefaultConstructor exists trivial constexpr needs_implicit defaulted_is_constexpr{{$}}
453 // CHECK-NEXT: | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param{{$}}
454 // CHECK-NEXT: | |-MoveConstructor exists simple trivial needs_implicit{{$}}
455 // CHECK-NEXT: | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param{{$}}
456 // CHECK-NEXT: | |-MoveAssignment exists simple trivial needs_implicit{{$}}
457 // CHECK-NEXT: | `-Destructor simple irrelevant trivial needs_implicit{{$}}
458 // CHECK-NEXT: `-CXXRecordDecl 0x{{.+}} <col:24, col:31> col:31 implicit struct TestTemplateDefaultType{{$}}
460 // CHECK: ClassTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-148]]:3, col:31> col:31 TestTemplateDefaultNonType{{$}}
461 // CHECK-NEXT: |-NonTypeTemplateParmDecl 0x{{.+}} <col:12, col:20> col:16 'int' depth 0 index 0 I{{$}}
462 // CHECK-NEXT: | `-TemplateArgument expr{{$}}
463 // CHECK-NEXT: | `-IntegerLiteral 0x{{.+}} <col:20> 'int' 42{{$}}
464 // CHECK-NEXT: `-CXXRecordDecl 0x{{.+}} <col:24, col:31> col:31 struct TestTemplateDefaultNonType{{$}}
466 // CHECK: ClassTemplateDecl 0x{{.+}} <{{.+}}:{{.*}}:3, col:68> col:68 TestTemplateTemplateDefaultType{{$}}
467 // CHECK-NEXT: |-TemplateTemplateParmDecl 0x{{.+}} <col:12, col:42> col:37 depth 0 index 0 TT{{$}}
468 // CHECK-NEXT: | |-TemplateTypeParmDecl 0x{{.+}} <col:21> col:29 typename depth 1 index 0{{$}}
469 // CHECK-NEXT: | `-TemplateArgument <col:42> template TestClassTemplate{{$}}
470 // CHECK-NEXT: `-CXXRecordDecl 0x{{.+}} <col:61, col:68> col:68 struct TestTemplateTemplateDefaultType{{$}}
472 // CHECK: ClassTemplateDecl 0x{{.+}} prev 0x{{.+}} <{{.+}}:{{.*}}:3, col:82> col:48 TestTemplateTemplateDefaultType{{$}}
473 // CHECK-NEXT: |-TemplateTemplateParmDecl 0x{{.+}} <col:12, col:37> col:37 depth 0 index 0 TT{{$}}
474 // CHECK-NEXT: | |-TemplateTypeParmDecl 0x{{.+}} <col:21> col:29 typename depth 1 index 0{{$}}
475 // CHECK-NEXT: | `-TemplateArgument <line:{{.*}}:42> template TestClassTemplate{{$}}
476 // CHECK-NEXT: | `-inherited from TemplateTemplateParm 0x{{.+}} 'TT'{{$}}
477 // CHECK-NEXT: `-CXXRecordDecl 0x{{.+}} prev 0x{{.+}} <line:{{.*}}:41, col:82> col:48 struct TestTemplateTemplateDefaultType definition{{$}}
478 // CHECK-NEXT: |-DefinitionData empty aggregate standard_layout trivially_copyable pod trivial literal has_constexpr_non_copy_move_ctor can_const_default_init{{$}}
479 // CHECK-NEXT: | |-DefaultConstructor exists trivial constexpr needs_implicit defaulted_is_constexpr{{$}}
480 // CHECK-NEXT: | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param{{$}}
481 // CHECK-NEXT: | |-MoveConstructor exists simple trivial needs_implicit{{$}}
482 // CHECK-NEXT: | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param{{$}}
483 // CHECK-NEXT: | |-MoveAssignment exists simple trivial needs_implicit{{$}}
484 // CHECK-NEXT: | `-Destructor simple irrelevant trivial needs_implicit{{$}}
485 // CHECK-NEXT: `-CXXRecordDecl 0x{{.+}} <col:41, col:48> col:48 implicit struct TestTemplateTemplateDefaultType{{$}}
488 // PR15220 dump instantiation only once
489 namespace testCanonicalTemplate
{
492 template<typename T
> void TestFunctionTemplate(T
);
493 template<typename T
> void TestFunctionTemplate(T
);
494 void bar(A a
) { TestFunctionTemplate(a
); }
495 // CHECK: FunctionTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-3]]:3, col:51> col:29 TestFunctionTemplate{{$}}
496 // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <col:12, col:21> col:21 referenced typename depth 0 index 0 T{{$}}
497 // CHECK-NEXT: |-FunctionDecl 0x{{.*}} <col:24, col:51> col:29 TestFunctionTemplate 'void (T)'{{$}}
498 // CHECK-NEXT: | `-ParmVarDecl 0x{{.*}} <col:50> col:51 'T'{{$}}
499 // CHECK-NEXT: `-FunctionDecl 0x{{.*}} <line:[[@LINE-6]]:24, col:51> col:29 used TestFunctionTemplate 'void (testCanonicalTemplate::A)' implicit_instantiation{{$}}
500 // CHECK-NEXT: |-TemplateArgument type 'testCanonicalTemplate::A'{{$}}
501 // CHECK-NEXT: | `-RecordType 0x{{.+}} 'testCanonicalTemplate::A'{{$}}
502 // CHECK-NEXT: | `-CXXRecord 0x{{.+}} 'A'{{$}}
503 // CHECK-NEXT: `-ParmVarDecl 0x{{.*}} <col:50> col:51 'testCanonicalTemplate::A'{{$}}
505 // CHECK: FunctionTemplateDecl 0x{{.+}} prev 0x{{.+}} <{{.+}}:[[@LINE-12]]:3, col:51> col:29 TestFunctionTemplate{{$}}
506 // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <col:12, col:21> col:21 referenced typename depth 0 index 0 T{{$}}
507 // CHECK-NEXT: |-FunctionDecl{{.*}} 0x{{.+}} prev 0x{{.+}} <col:24, col:51> col:29 TestFunctionTemplate 'void (T)'{{$}}
508 // CHECK-NEXT: | `-ParmVarDecl 0x{{.+}} <col:50> col:51 'T'{{$}}
509 // CHECK-NEXT: `-Function 0x{{.+}} 'TestFunctionTemplate' 'void (testCanonicalTemplate::A)'{{$}}
510 // CHECK-NOT: TemplateArgument{{$}}
512 template<typename T1
> class TestClassTemplate
{
513 template<typename T2
> friend class TestClassTemplate
;
515 TestClassTemplate
<A
> a
;
516 // CHECK: ClassTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-4]]:3, line:[[@LINE-2]]:3> line:[[@LINE-4]]:31 TestClassTemplate{{$}}
517 // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <col:12, col:21> col:21 typename depth 0 index 0 T1{{$}}
518 // CHECK-NEXT: |-CXXRecordDecl 0x{{.+}} <col:25, line:[[@LINE-4]]:3> line:[[@LINE-6]]:31 class TestClassTemplate definition{{$}}
519 // CHECK-NEXT: | |-DefinitionData empty aggregate standard_layout trivially_copyable pod trivial literal has_constexpr_non_copy_move_ctor can_const_default_init{{$}}
520 // CHECK-NEXT: | | |-DefaultConstructor exists trivial constexpr needs_implicit defaulted_is_constexpr{{$}}
521 // CHECK-NEXT: | | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param{{$}}
522 // CHECK-NEXT: | | |-MoveConstructor exists simple trivial needs_implicit{{$}}
523 // CHECK-NEXT: | | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param{{$}}
524 // CHECK-NEXT: | | |-MoveAssignment exists simple trivial needs_implicit{{$}}
525 // CHECK-NEXT: | | `-Destructor simple irrelevant trivial needs_implicit{{$}}
526 // CHECK-NEXT: | |-CXXRecordDecl 0x{{.+}} <col:25, col:31> col:31 implicit class TestClassTemplate{{$}}
527 // CHECK-NEXT: | `-FriendDecl 0x{{.+}} <line:[[@LINE-14]]:5, col:40> col:40{{$}}
528 // CHECK-NEXT: | `-ClassTemplateDecl 0x{{.+}} parent 0x{{.+}} <col:5, col:40> col:40 friend_undeclared TestClassTemplate{{$}}
529 // CHECK-NEXT: | |-TemplateTypeParmDecl 0x{{.+}} <col:14, col:23> col:23 typename depth 1 index 0 T2{{$}}
530 // CHECK-NEXT: | `-CXXRecordDecl 0x{{.+}} parent 0x{{.+}} <col:34, col:40> col:40 class TestClassTemplate{{$}}
531 // CHECK-NEXT: `-ClassTemplateSpecializationDecl 0x{{.+}} <line:[[@LINE-19]]:3, line:[[@LINE-17]]:3> line:[[@LINE-19]]:31 class TestClassTemplate definition implicit_instantiation{{$}}
532 // CHECK-NEXT: |-DefinitionData pass_in_registers empty aggregate standard_layout trivially_copyable pod trivial literal has_constexpr_non_copy_move_ctor can_const_default_init{{$}}
533 // CHECK-NEXT: | |-DefaultConstructor exists trivial constexpr defaulted_is_constexpr{{$}}
534 // CHECK-NEXT: | |-CopyConstructor simple trivial has_const_param implicit_has_const_param{{$}}
535 // CHECK-NEXT: | |-MoveConstructor exists simple trivial{{$}}
536 // CHECK-NEXT: | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param{{$}}
537 // CHECK-NEXT: | |-MoveAssignment exists simple trivial needs_implicit{{$}}
538 // CHECK-NEXT: | `-Destructor simple irrelevant trivial needs_implicit{{$}}
539 // CHECK-NEXT: |-TemplateArgument type 'testCanonicalTemplate::A'{{$}}
540 // CHECK-NEXT: | `-RecordType 0x{{.+}} 'testCanonicalTemplate::A'{{$}}
541 // CHECK-NEXT: | `-CXXRecord 0x{{.+}} 'A'{{$}}
542 // CHECK-NEXT: |-CXXRecordDecl 0x{{.+}} <col:25, col:31> col:31 implicit class TestClassTemplate{{$}}
543 // CHECK-NEXT: |-FriendDecl 0x{{.+}} <line:[[@LINE-30]]:5, col:40> col:40{{$}}
544 // CHECK-NEXT: | `-ClassTemplateDecl 0x{{.+}} parent 0x{{.+}} prev 0x{{.+}} <col:5, col:40> col:40 friend TestClassTemplate{{$}}
545 // CHECK-NEXT: | |-TemplateTypeParmDecl 0x{{.+}} <col:14, col:23> col:23 typename depth 0 index 0 T2{{$}}
546 // CHECK-NEXT: | |-CXXRecordDecl 0x{{.+}} parent 0x{{.+}} prev 0x{{.+}} <col:34, col:40> col:40 class TestClassTemplate{{$}}
547 // CHECK-NEXT: | `-ClassTemplateSpecialization 0x{{.+}} 'TestClassTemplate'{{$}}
548 // CHECK-NEXT: |-CXXConstructorDecl 0x{{.+}} <line:[[@LINE-36]]:31> col:31 implicit used constexpr TestClassTemplate 'void () noexcept' inline default trivial{{$}}
549 // CHECK-NEXT: | `-CompoundStmt 0x{{.+}} <col:31>{{$}}
550 // CHECK-NEXT: |-CXXConstructorDecl 0x{{.+}} <col:31> col:31 implicit constexpr TestClassTemplate 'void (const TestClassTemplate<A> &)' inline default trivial noexcept-unevaluated 0x{{.+}}{{$}}
551 // CHECK-NEXT: | `-ParmVarDecl 0x{{.+}} <col:31> col:31 'const TestClassTemplate<A> &'{{$}}
552 // CHECK-NEXT: `-CXXConstructorDecl 0x{{.+}} <col:31> col:31 implicit constexpr TestClassTemplate 'void (TestClassTemplate<A> &&)' inline default trivial noexcept-unevaluated 0x{{.+}}{{$}}
553 // CHECK-NEXT: `-ParmVarDecl 0x{{.+}} <col:31> col:31 'TestClassTemplate<A> &&'{{$}}
556 template<typename T1
> class TestClassTemplate2
;
557 template<typename T1
> class TestClassTemplate2
;
558 template<typename T1
> class TestClassTemplate2
{
560 TestClassTemplate2
<A
> a2
;
561 // CHECK: ClassTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-5]]:3, col:31> col:31 TestClassTemplate2{{$}}
562 // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <col:12, col:21> col:21 typename depth 0 index 0 T1{{$}}
563 // CHECK-NEXT: |-CXXRecordDecl 0x{{.+}} <col:25, col:31> col:31 class TestClassTemplate2{{$}}
564 // CHECK-NEXT: `-ClassTemplateSpecializationDecl 0x{{.+}} <line:[[@LINE-6]]:3, line:[[@LINE-5]]:3> line:[[@LINE-6]]:31 class TestClassTemplate2 definition implicit_instantiation{{$}}
565 // CHECK-NEXT: |-DefinitionData pass_in_registers empty aggregate standard_layout trivially_copyable pod trivial literal has_constexpr_non_copy_move_ctor can_const_default_init{{$}}
566 // CHECK-NEXT: | |-DefaultConstructor exists trivial constexpr defaulted_is_constexpr{{$}}
567 // CHECK-NEXT: | |-CopyConstructor simple trivial has_const_param implicit_has_const_param{{$}}
568 // CHECK-NEXT: | |-MoveConstructor exists simple trivial{{$}}
569 // CHECK-NEXT: | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param{{$}}
570 // CHECK-NEXT: | |-MoveAssignment exists simple trivial needs_implicit{{$}}
571 // CHECK-NEXT: | `-Destructor simple irrelevant trivial needs_implicit{{$}}
572 // CHECK-NEXT: |-TemplateArgument type 'testCanonicalTemplate::A'{{$}}
573 // CHECK-NEXT: | `-RecordType 0x{{.+}} 'testCanonicalTemplate::A'{{$}}
574 // CHECK-NEXT: | `-CXXRecord 0x{{.+}} 'A'{{$}}
575 // CHECK-NEXT: |-CXXRecordDecl 0x{{.+}} <col:25, col:31> col:31 implicit class TestClassTemplate2{{$}}
576 // CHECK-NEXT: |-CXXConstructorDecl 0x{{.+}} <col:31> col:31 implicit used constexpr TestClassTemplate2 'void () noexcept' inline default trivial{{$}}
577 // CHECK-NEXT: | `-CompoundStmt 0x{{.+}} <col:31>{{$}}
578 // CHECK-NEXT: |-CXXConstructorDecl 0x{{.+}} <col:31> col:31 implicit constexpr TestClassTemplate2 'void (const TestClassTemplate2<A> &)' inline default trivial noexcept-unevaluated 0x{{.+}}{{$}}
579 // CHECK-NEXT: | `-ParmVarDecl 0x{{.+}} <col:31> col:31 'const TestClassTemplate2<A> &'{{$}}
580 // CHECK-NEXT: `-CXXConstructorDecl 0x{{.+}} <col:31> col:31 implicit constexpr TestClassTemplate2 'void (TestClassTemplate2<A> &&)' inline default trivial noexcept-unevaluated 0x{{.+}}{{$}}
581 // CHECK-NEXT: `-ParmVarDecl 0x{{.+}} <col:31> col:31 'TestClassTemplate2<A> &&'{{$}}
583 // CHECK: ClassTemplateDecl 0x{{.+}} prev 0x{{.+}} <{{.+}}:[[@LINE-26]]:3, col:31> col:31 TestClassTemplate2{{$}}
584 // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <col:12, col:21> col:21 typename depth 0 index 0 T1{{$}}
585 // CHECK-NEXT: |-CXXRecordDecl 0x{{.+}} prev 0x{{.+}} <col:25, col:31> col:31 class TestClassTemplate2{{$}}
586 // CHECK-NEXT: `-ClassTemplateSpecialization 0x{{.+}} 'TestClassTemplate2'{{$}}
588 // CHECK: ClassTemplateDecl 0x{{.+}} prev 0x{{.+}} <{{.+}}:[[@LINE-30]]:3, line:[[@LINE-29]]:3> line:[[@LINE-30]]:31 TestClassTemplate2{{$}}
589 // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <col:12, col:21> col:21 typename depth 0 index 0 T1{{$}}
590 // CHECK-NEXT: |-CXXRecordDecl 0x{{.+}} prev 0x{{.+}} <col:25, line:[[@LINE-31]]:3> line:[[@LINE-32]]:31 class TestClassTemplate2 definition{{$}}
591 // CHECK-NEXT: | |-DefinitionData empty aggregate standard_layout trivially_copyable pod trivial literal has_constexpr_non_copy_move_ctor can_const_default_init{{$}}
592 // CHECK-NEXT: | | |-DefaultConstructor exists trivial constexpr needs_implicit defaulted_is_constexpr{{$}}
593 // CHECK-NEXT: | | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param{{$}}
594 // CHECK-NEXT: | | |-MoveConstructor exists simple trivial needs_implicit{{$}}
595 // CHECK-NEXT: | | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param{{$}}
596 // CHECK-NEXT: | | |-MoveAssignment exists simple trivial needs_implicit{{$}}
597 // CHECK-NEXT: | | `-Destructor simple irrelevant trivial needs_implicit{{$}}
598 // CHECK-NEXT: | `-CXXRecordDecl 0x{{.+}} <col:25, col:31> col:31 implicit class TestClassTemplate2{{$}}
599 // CHECK-NEXT: `-ClassTemplateSpecialization 0x{{.+}} 'TestClassTemplate2'{{$}}
602 template<typename T
> static const T TestVarTemplate
; // declaration of a static data member template
605 const T
S::TestVarTemplate
= { }; // definition of a static data member template
609 int i
= S::TestVarTemplate
<int>;
610 int j
= S::TestVarTemplate
<int>;
613 // CHECK: VarTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-11]]:7, col:43> col:43 TestVarTemplate{{$}}
614 // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <col:16, col:25> col:25 referenced typename depth 0 index 0 T{{$}}
615 // CHECK-NEXT: |-VarDecl 0x{{.+}} <col:28, col:43> col:43 TestVarTemplate 'const T' static{{$}}
616 // CHECK-NEXT: |-VarTemplateSpecializationDecl 0x{{.+}} parent 0x{{.+}} prev 0x{{.+}} <line:[[@LINE-11]]:3, col:34> col:14 referenced TestVarTemplate 'const int' implicit_instantiation cinit{{$}}
617 // CHECK-NEXT: | |-NestedNameSpecifier TypeSpec 'testCanonicalTemplate::S'{{$}}
618 // CHECK-NEXT: | |-TemplateArgument type 'int'{{$}}
619 // CHECK-NEXT: | | `-BuiltinType 0x{{.+}} 'int'{{$}}
620 // CHECK-NEXT: | `-InitListExpr 0x{{.+}} <col:32, col:34> 'int'{{$}}
621 // CHECK-NEXT: `-VarTemplateSpecializationDecl 0x{{.+}} <line:[[@LINE-19]]:28, col:43> col:43 referenced TestVarTemplate 'const int' implicit_instantiation static{{$}}
622 // CHECK-NEXT: `-TemplateArgument type 'int'{{$}}
624 // CHECK: VarTemplateSpecializationDecl 0x{{.+}} <{{.+}}:[[@LINE-22]]:28, col:43> col:43 referenced TestVarTemplate 'const int' implicit_instantiation static{{$}}
625 // CHECK-NEXT:`-TemplateArgument type 'int'{{$}}
626 // CHECK-NEXT: `-BuiltinType 0x{{.+}} 'int'{{$}}
628 // CHECK: VarTemplateDecl 0x{{.+}} parent 0x{{.+}} prev 0x{{.+}} <{{.+}}:[[@LINE-24]]:3, line:[[@LINE-23]]:34> col:14 TestVarTemplate{{$}}
629 // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <line:[[@LINE-25]]:12, col:21> col:21 referenced typename depth 0 index 0 T{{$}}
630 // CHECK-NEXT: |-VarDecl 0x{{.+}} parent 0x{{.+}} prev 0x{{.+}} <line:[[@LINE-25]]:3, col:34> col:14 TestVarTemplate 'const T' cinit{{$}}
631 // CHECK-NEXT: | |-NestedNameSpecifier TypeSpec 'testCanonicalTemplate::S'{{$}}
632 // CHECK-NEXT: | `-InitListExpr 0x{{.+}} <col:32, col:34> 'void'{{$}}
633 // CHECK-NEXT: |-VarTemplateSpecialization 0x{{.+}} 'TestVarTemplate' 'const int'{{$}}
634 // CHECK-NEXT: `-VarTemplateSpecialization 0x{{.+}} 'TestVarTemplate' 'const int'{{$}}
636 // CHECK: VarTemplateSpecializationDecl 0x{{.+}} parent 0x{{.+}} prev 0x{{.+}} <{{.+}}:[[@LINE-31]]:3, col:34> col:14 referenced TestVarTemplate 'const int' implicit_instantiation cinit{{$}}
637 // CHECK-NEXT: |-NestedNameSpecifier TypeSpec 'testCanonicalTemplate::S'{{$}}
638 // CHECK-NEXT: |-TemplateArgument type 'int'{{$}}
639 // CHECK-NEXT: | `-BuiltinType 0x{{.+}} 'int'{{$}}
640 // CHECK-NEXT: `-InitListExpr 0x{{.+}} <col:32, col:34> 'int'{{$}}
644 class TestClassScopeFunctionSpecialization
{
645 template<class U
> void foo(U a
) { }
646 template<> void foo
<int>(int a
) { }
648 // CHECK: FunctionTemplateDecl{{.*}} foo
649 // CHECK-NEXT: TemplateTypeParmDecl{{.*}} referenced class depth 1 index 0 U
650 // CHECK-NEXT: CXXMethodDecl{{.*}} foo 'void (U)' implicit-inline
651 // CHECK-NEXT: ParmVarDecl
652 // CHECK-NEXT: CompoundStmt
653 // CHECK-NEXT: CXXMethodDecl{{.*}} foo 'void (int)' explicit_specialization implicit-inline
654 // CHECK-NEXT: TemplateArgument{{.*}} 'int'
655 // CHECK-NEXT: BuiltinType{{.*}} 'int'
656 // CHECK-NEXT: ParmVarDecl
657 // CHECK-NEXT: CompoundStmt
659 namespace TestTemplateTypeParmDecl
{
660 template<typename
... T
, class U
= int> void foo();
662 // CHECK: NamespaceDecl{{.*}} TestTemplateTypeParmDecl
663 // CHECK-NEXT: FunctionTemplateDecl
664 // CHECK-NEXT: TemplateTypeParmDecl{{.*}} typename depth 0 index 0 ... T
665 // CHECK-NEXT: TemplateTypeParmDecl{{.*}} class depth 0 index 1 U
666 // CHECK-NEXT: TemplateArgument type 'int'
668 namespace TestNonTypeTemplateParmDecl
{
669 template<int I
= 1, int ... J
> void foo();
671 // CHECK: NamespaceDecl{{.*}} TestNonTypeTemplateParmDecl
672 // CHECK-NEXT: FunctionTemplateDecl
673 // CHECK-NEXT: NonTypeTemplateParmDecl{{.*}} 'int' depth 0 index 0 I
674 // CHECK-NEXT: TemplateArgument expr
675 // CHECK-NEXT: IntegerLiteral{{.*}} 'int' 1
676 // CHECK-NEXT: NonTypeTemplateParmDecl{{.*}} 'int' depth 0 index 1 ... J
678 namespace TestTemplateTemplateParmDecl
{
679 template<typename T
> class A
;
680 template <template <typename
> class T
= A
, template <typename
> class ... U
> void foo();
682 // CHECK: NamespaceDecl{{.*}} TestTemplateTemplateParmDecl
683 // CHECK: FunctionTemplateDecl
684 // CHECK-NEXT: TemplateTemplateParmDecl{{.*}} T
685 // CHECK-NEXT: TemplateTypeParmDecl{{.*}} typename
686 // CHECK-NEXT: TemplateArgument{{.*}} template A
687 // CHECK-NEXT: TemplateTemplateParmDecl{{.*}} ... U
688 // CHECK-NEXT: TemplateTypeParmDecl{{.*}} typename
690 namespace TestTemplateArgument
{
691 template<typename
> class A
{ };
692 template<template<typename
> class ...> class B
{ };
695 template<typename
> class testType
{ };
696 template class testType
<int>;
697 // CHECK: ClassTemplateSpecializationDecl{{.*}} class testType
698 // CHECK: TemplateArgument{{.*}} type 'int'
700 template<int fp(void)> class testDecl
{ };
701 template class testDecl
<foo
>;
702 // CHECK: ClassTemplateSpecializationDecl{{.*}} class testDecl
703 // CHECK: TemplateArgument{{.*}} decl
704 // CHECK-NEXT: Function{{.*}}foo
706 template class testDecl
<nullptr>;
707 // CHECK: ClassTemplateSpecializationDecl{{.*}} class testDecl
708 // CHECK: TemplateArgument{{.*}} nullptr
710 template<int> class testIntegral
{ };
711 template class testIntegral
<1>;
712 // CHECK: ClassTemplateSpecializationDecl{{.*}} class testIntegral
713 // CHECK: TemplateArgument{{.*}} integral 1
715 template<template<typename
> class> class testTemplate
{ };
716 template class testTemplate
<A
>;
717 // CHECK: ClassTemplateSpecializationDecl{{.*}} class testTemplate
718 // CHECK: TemplateArgument{{.*}} A
720 template<template<typename
> class ...T
> class C
{
721 B
<T
...> testTemplateExpansion
;
723 // FIXME: Need TemplateSpecializationType dumping to test TemplateExpansion.
725 template<int, int = 0> class testExpr
;
726 template<int I
> class testExpr
<I
> { };
727 // CHECK: ClassTemplatePartialSpecializationDecl{{.*}} class testExpr
728 // CHECK: TemplateArgument{{.*}} expr
729 // CHECK-NEXT: DeclRefExpr{{.*}}I
731 template<int, int ...> class testPack
{ };
732 template class testPack
<0, 1, 2>;
733 // CHECK: ClassTemplateSpecializationDecl{{.*}} class testPack
734 // CHECK: TemplateArgument{{.*}} integral 0
735 // CHECK-NEXT: TemplateArgument{{.*}} pack
736 // CHECK-NEXT: TemplateArgument{{.*}} integral 1
737 // CHECK-NEXT: TemplateArgument{{.*}} integral 2
740 namespace testUsingDecl
{
743 namespace TestUsingDecl
{
744 using testUsingDecl::i
;
746 // CHECK: NamespaceDecl{{.*}} TestUsingDecl
747 // CHECK-NEXT: UsingDecl{{.*}} testUsingDecl::i
748 // CHECK-NEXT: | `-NestedNameSpecifier Namespace 0x{{.*}} 'testUsingDecl
749 // CHECK-NEXT: UsingShadowDecl{{.*}} Var{{.*}} 'i' 'int'
751 namespace testUnresolvedUsing
{
753 template<class T
> class B
{
757 template<class T
> class TestUnresolvedUsing
: public B
<T
> {
758 using typename B
<T
>::a
;
762 // CHECK: CXXRecordDecl{{.*}} TestUnresolvedUsing
763 // CHECK: UnresolvedUsingTypenameDecl{{.*}} B<T>::a
764 // CHECK: UnresolvedUsingValueDecl{{.*}} B<T>::a
766 namespace TestLinkageSpecDecl
{
767 extern "C" void test1();
768 extern "C++" void test2();
770 // CHECK: NamespaceDecl{{.*}} TestLinkageSpecDecl
771 // CHECK-NEXT: LinkageSpecDecl{{.*}} C
772 // CHECK-NEXT: FunctionDecl
773 // CHECK-NEXT: LinkageSpecDecl{{.*}} C++
774 // CHECK-NEXT: FunctionDecl
776 class TestAccessSpecDecl
{
781 // CHECK: CXXRecordDecl{{.*}} class TestAccessSpecDecl
782 // CHECK: CXXRecordDecl{{.*}} class TestAccessSpecDecl
783 // CHECK-NEXT: AccessSpecDecl{{.*}} public
784 // CHECK-NEXT: AccessSpecDecl{{.*}} private
785 // CHECK-NEXT: AccessSpecDecl{{.*}} protected
787 template<typename T
> class TestFriendDecl
{
792 // CHECK: CXXRecord{{.*}} TestFriendDecl
793 // CHECK: CXXRecord{{.*}} TestFriendDecl
794 // CHECK-NEXT: FriendDecl
795 // CHECK-NEXT: FunctionDecl{{.*}} foo
796 // CHECK-NEXT: FriendDecl{{.*}} 'class A':'A'
797 // CHECK-NEXT: CXXRecordDecl{{.*}} class A
798 // CHECK-NEXT: FriendDecl{{.*}} 'T'
800 namespace TestFileScopeAsmDecl
{
803 // CHECK: NamespaceDecl{{.*}} TestFileScopeAsmDecl{{$}}
804 // CHECK: FileScopeAsmDecl{{.*> .*$}}
805 // CHECK-NEXT: StringLiteral
807 namespace TestFriendDecl2
{
813 // CHECK: NamespaceDecl [[TestFriendDecl2:0x.*]] <{{.*}}> {{.*}} TestFriendDecl2
814 // CHECK: |-FunctionDecl [[TestFriendDecl2_f:0x.*]] <{{.*}}> {{.*}} f 'void ()'
815 // CHECK: `-CXXRecordDecl {{.*}} struct S
816 // CHECK: |-CXXRecordDecl {{.*}} struct S
817 // CHECK: `-FriendDecl
818 // CHECK: `-FunctionDecl {{.*}} parent [[TestFriendDecl2]] prev [[TestFriendDecl2_f]] <{{.*}}> {{.*}} f 'void ()'
827 // CHECK: VarDecl {{.*}} Test 'int' extern
828 // CHECK-NOT: FullComment
829 // CHECK: VarDecl {{.*}} Test 'int' extern
830 // CHECK: `-FullComment
831 // CHECK: `-ParagraphComment
832 // CHECK: `-TextComment
833 // CHECK: VarDecl {{.*}} Test 'int' extern
834 // CHECK-NOT: FullComment
836 namespace TestConstexprVariableTemplateWithInitializer
{
837 template<typename T
> constexpr T foo
{};
838 // CHECK: VarTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-1]]:3, col:40> col:36 foo{{$}}
839 // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <col:12, col:21> col:21 referenced typename depth 0 index 0 T{{$}}
840 // CHECK-NEXT: `-VarDecl 0x{{.+}} <col:24, col:40> col:36 foo 'const T' constexpr listinit{{$}}
841 // CHECK-NEXT: `-InitListExpr 0x{{.+}} <col:39, col:40> 'void'{{$}}
843 template<typename T
> constexpr int val
{42};
844 // CHECK: VarTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-1]]:3, col:44> col:38 val{{$}}
845 // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <col:12, col:21> col:21 typename depth 0 index 0 T{{$}}
846 // CHECK-NEXT: `-VarDecl 0x{{.+}} <col:24, col:44> col:38 val 'const int' constexpr listinit{{$}}
847 // CHECK-NEXT: |-value: Int 42{{$}}
848 // CHECK-NEXT: `-InitListExpr 0x{{.+}} <col:41, col:44> 'int'{{$}}
850 template <typename _Tp
>
851 struct in_place_type_t
{
852 explicit in_place_type_t() = default;
855 template <typename _Tp
>
856 inline constexpr in_place_type_t
<_Tp
> in_place_type
{};
857 // CHECK: -VarTemplateDecl 0x{{.+}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:55> col:41 in_place_type{{$}}
858 // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <line:[[@LINE-3]]:13, col:22> col:22 referenced typename depth 0 index 0 _Tp{{$}}
859 // CHECK-NEXT: `-VarDecl 0x{{.+}} <line:[[@LINE-3]]:3, col:55> col:41 in_place_type 'const in_place_type_t<_Tp>' inline constexpr listinit{{$}}
860 // CHECK-NEXT: `-InitListExpr 0x{{.+}} <col:54, col:55> 'void'{{$}}
862 template <typename T
> constexpr T
call_init(0);
863 // CHECK: -VarTemplateDecl 0x{{.+}} <line:[[@LINE-1]]:3, col:48> col:37 call_init{{$}}
864 // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <col:13, col:22> col:22 referenced typename depth 0 index 0 T{{$}}
865 // CHECK-NEXT: `-VarDecl 0x{{.+}} <col:25, col:48> col:37 call_init 'const T' constexpr callinit{{$}}
866 // CHECK-NEXT: `-ParenListExpr 0x{{.+}} <col:46, col:48> 'NULL TYPE'{{$}}
867 // CHECK-NEXT: `-IntegerLiteral 0x{{.+}} <col:47> 'int' 0{{$}}