xref: /llvm-project/clang/test/AST/ast-dump-decl.cpp (revision eda9d27a91e6f3bf6d7c65a300be729c410e93a7)
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
5 //
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
12 
13 class testEnumDecl {
14   enum class TestEnumDeclScoped;
15   enum TestEnumDeclFixed : int;
16 };
17 // CHECK: EnumDecl{{.*}} class TestEnumDeclScoped 'int'
18 // CHECK: EnumDecl{{.*}} TestEnumDeclFixed 'int'
19 
20 class testFieldDecl {
21   int TestFieldDeclInit = 0;
22 };
23 // CHECK:      FieldDecl{{.*}} TestFieldDeclInit 'int'
24 // CHECK-NEXT:   IntegerLiteral
25 
26 namespace testVarDeclNRVO {
27   class A { };
28   A TestFuncNRVO() {
29     A TestVarDeclNRVO;
30     return TestVarDeclNRVO;
31   }
32 }
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')
39 
40 void testParmVarDeclInit(int TestParmVarDeclInit = 0);
41 // CHECK:      ParmVarDecl{{.*}} TestParmVarDeclInit 'int'
42 // CHECK-NEXT:   IntegerLiteral{{.*}}
43 
44 namespace TestNamespaceDecl {
45   int i;
46 }
47 // CHECK:      NamespaceDecl{{.*}} TestNamespaceDecl
48 // CHECK-NEXT:   VarDecl
49 
50 namespace TestNamespaceDecl {
51   int j;
52 }
53 // CHECK:      NamespaceDecl{{.*}} TestNamespaceDecl
54 // CHECK-NEXT:   original Namespace
55 // CHECK-NEXT:   VarDecl
56 
57 inline namespace TestNamespaceDeclInline {
58 }
59 // CHECK:      NamespaceDecl{{.*}} TestNamespaceDeclInline inline
60 
61 namespace TestNestedNameSpace::Nested {
62 }
63 // CHECK:      NamespaceDecl{{.*}} TestNestedNameSpace
64 // CHECK:      NamespaceDecl{{.*}} Nested nested{{\s*$}}
65 
66 namespace TestMultipleNested::SecondLevelNested::Nested {
67 }
68 // CHECK:      NamespaceDecl{{.*}} TestMultipleNested
69 // CHECK:      NamespaceDecl{{.*}} SecondLevelNested nested
70 // CHECK:      NamespaceDecl{{.*}} Nested nested{{\s*$}}
71 
72 namespace TestInlineNested::inline SecondLevel::inline Nested {
73 }
74 // CHECK:      NamespaceDecl{{.*}} TestInlineNested
75 // CHECK:      NamespaceDecl{{.*}} SecondLevel inline nested
76 // CHECK:      NamespaceDecl{{.*}} Nested inline nested{{\s*$}}
77 
78 namespace testUsingDirectiveDecl {
79   namespace A {
80   }
81 }
82 namespace TestUsingDirectiveDecl {
83   using namespace testUsingDirectiveDecl::A;
84 }
85 // CHECK:      NamespaceDecl{{.*}} TestUsingDirectiveDecl
86 // CHECK-NEXT:   UsingDirectiveDecl{{.*}} Namespace{{.*}} 'A'
87 
88 namespace testNamespaceAlias {
89   namespace A {
90   }
91 }
92 namespace TestNamespaceAlias = testNamespaceAlias::A;
93 // CHECK:      NamespaceAliasDecl{{.*}} TestNamespaceAlias
94 // CHECK-NEXT:   Namespace{{.*}} 'A'
95 
96 using TestTypeAliasDecl = int;
97 // CHECK: TypeAliasDecl{{.*}} TestTypeAliasDecl 'int'
98 
99 namespace testTypeAliasTemplateDecl {
100   template<typename T> class A;
101   template<typename T> using TestTypeAliasTemplateDecl = A<T>;
102 }
103 // CHECK:      TypeAliasTemplateDecl{{.*}} TestTypeAliasTemplateDecl
104 // CHECK-NEXT:   TemplateTypeParmDecl
105 // CHECK-NEXT:   TypeAliasDecl{{.*}} TestTypeAliasTemplateDecl 'A<T>'
106 
107 namespace testCXXRecordDecl {
108   class TestEmpty {};
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
117 
118   class A { };
119   class B { };
120   class TestCXXRecordDecl : virtual A, public B {
121     int i;
122   };
123 }
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
136 
137 template<class...T>
138 class TestCXXRecordDeclPack : public T... {
139 };
140 // CHECK:      CXXRecordDecl{{.*}} class TestCXXRecordDeclPack
141 // CHECK:        public 'T'...
142 // CHECK-NEXT:   CXXRecordDecl{{.*}} class TestCXXRecordDeclPack
143 
144 thread_local int TestThreadLocalInt;
145 // CHECK: TestThreadLocalInt {{.*}} tls_dynamic
146 
147 class testCXXMethodDecl {
148   virtual void TestCXXMethodDeclPure() = 0;
149   void TestCXXMethodDeclDelete() = delete;
150   void TestCXXMethodDeclThrow() throw();
151   void TestCXXMethodDeclThrowType() throw(int);
152 };
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)'
157 
158 namespace testCXXConstructorDecl {
159   class A { };
160   class TestCXXConstructorDecl : public A {
161     int I;
162     TestCXXConstructorDecl(A &a, int i) : A(a), I(i) { }
163     TestCXXConstructorDecl(A &a) : TestCXXConstructorDecl(a, 0) { }
164   };
165 }
166 // CHECK:      CXXConstructorDecl{{.*}} TestCXXConstructorDecl 'void {{.*}}'
167 // CHECK-NEXT:   ParmVarDecl{{.*}} a
168 // CHECK-NEXT:   ParmVarDecl{{.*}} i
169 // CHECK-NEXT:   CXXCtorInitializer{{.*}}A
170 // CHECK-NEXT:     Expr
171 // CHECK:        CXXCtorInitializer{{.*}}I
172 // CHECK-NEXT:     Expr
173 // CHECK:        CompoundStmt
174 // CHECK:      CXXConstructorDecl{{.*}} TestCXXConstructorDecl 'void {{.*}}'
175 // CHECK-NEXT:   ParmVarDecl{{.*}} a
176 // CHECK-NEXT:   CXXCtorInitializer{{.*}}TestCXXConstructorDecl
177 // CHECK-NEXT:     CXXConstructExpr{{.*}}TestCXXConstructorDecl
178 
179 class TestCXXDestructorDecl {
180   ~TestCXXDestructorDecl() { }
181 };
182 // CHECK:      CXXDestructorDecl{{.*}} ~TestCXXDestructorDecl 'void () noexcept'
183 // CHECK-NEXT:   CompoundStmt
184 
185 // Test that the range of a defaulted members is computed correctly.
186 class TestMemberRanges {
187 public:
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;
194 };
195 void SomeFunction() {
196   TestMemberRanges A;
197   TestMemberRanges B(A);
198   B = A;
199   A = static_cast<TestMemberRanges &&>(B);
200   TestMemberRanges C(static_cast<TestMemberRanges &&>(A));
201 }
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>
208 
209 class TestCXXConversionDecl {
210   operator int() { return 0; }
211 };
212 // CHECK:      CXXConversionDecl{{.*}} operator int 'int ()'
213 // CHECK-NEXT:   CompoundStmt
214 
215 namespace TestStaticAssertDecl {
216   static_assert(true, "msg");
217 }
218 // CHECK:      NamespaceDecl{{.*}} TestStaticAssertDecl
219 // CHECK-NEXT:   StaticAssertDecl{{.*> .*$}}
220 // CHECK-NEXT:     CXXBoolLiteralExpr
221 // CHECK-NEXT:     StringLiteral
222 
223 namespace testFunctionTemplateDecl {
224   class A { };
225   class B { };
226   class C { };
227   class D { };
228   template<typename T> void TestFunctionTemplate(T) { }
229 
230   // implicit instantiation
231   void bar(A a) { TestFunctionTemplate(a); }
232 
233   // explicit specialization
234   template<> void TestFunctionTemplate(B);
235 
236   // explicit instantiation declaration
237   extern template void TestFunctionTemplate(C);
238 
239   // explicit instantiation definition
240   template void TestFunctionTemplate(D);
241 }
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':'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':'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':'testFunctionTemplateDecl::D'
264   // CHECK-NEXT:    `-CompoundStmt 0x{{.+}} <col:53, col:55>
265 
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'
271 
272 
273 namespace testClassTemplateDecl {
274   class A { };
275   class B { };
276   class C { };
277   class D { };
278 
279   template<typename T> class TestClassTemplate {
280   public:
281     TestClassTemplate();
282     ~TestClassTemplate();
283     int j();
284     int i;
285   };
286 
287   // implicit instantiation
288   TestClassTemplate<A> a;
289 
290   // explicit specialization
291   template<> class TestClassTemplate<B> {
292     int j;
293   };
294 
295   // explicit instantiation declaration
296   extern template class TestClassTemplate<C>;
297 
298   // explicit instantiation definition
299   template class TestClassTemplate<D>;
300 
301   // partial explicit specialization
302   template<typename T1, typename T2> class TestClassTemplatePartial {
303     int i;
304   };
305   template<typename T1> class TestClassTemplatePartial<T1, A> {
306     int j;
307   };
308 
309   template<typename T = int> struct TestTemplateDefaultType;
310   template<typename T> struct TestTemplateDefaultType { };
311 
312   template<int I = 42> struct TestTemplateDefaultNonType;
313   template<int I> struct TestTemplateDefaultNonType { };
314 
315   template<template<typename> class TT = TestClassTemplate> struct TestTemplateTemplateDefaultType;
316   template<template<typename> class TT> struct TestTemplateTemplateDefaultType { };
317 }
318 
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
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 ()'
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
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 ()'
349 // CHECK-NEXT:  | |-CXXDestructorDecl 0x{{.+}} <line:[[@LINE-67]]:5, col:24> col:5 used ~TestClassTemplate 'void () noexcept'
350 // CHECK-NEXT:  | |-CXXMethodDecl 0x{{.+}} <line:[[@LINE-67]]:5, col:11> col:9 j 'int ()'
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'
357 
358 // CHECK:       ClassTemplateSpecializationDecl 0x{{.+}} <{{.+}}:[[@LINE-67]]:3, line:[[@LINE-65]]:3> line:[[@LINE-67]]:20 class TestClassTemplate definition
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'
371 
372 // CHECK:       ClassTemplateSpecializationDecl 0x{{.+}} <{{.+}}:{{.*}}:3, col:44> col:25 class TestClassTemplate definition
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
386 // CHECK-NEXT:  |-CXXDestructorDecl 0x{{.+}} <line:[[@LINE-104]]:5, col:24> col:5 ~TestClassTemplate 'void ()' explicit_instantiation_declaration noexcept-unevaluated 0x{{.+}}
387 // CHECK-NEXT:  |-CXXMethodDecl 0x{{.+}} <line:[[@LINE-104]]:5, col:11> col:9 j 'int ()'
388 // CHECK-NEXT:  `-FieldDecl 0x{{.+}} <line:[[@LINE-104]]:5, col:9> col:9 i 'int'
389 
390 // CHECK:       ClassTemplateSpecializationDecl 0x{{.+}} <{{.+}}:[[@LINE-91]]:3, col:37> col:18 class TestClassTemplate 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
404 // CHECK-NEXT:  |-CXXDestructorDecl 0x{{.+}} <line:[[@LINE-122]]:5, col:24> col:5 ~TestClassTemplate 'void ()' implicit_instantiation noexcept-unevaluated 0x{{.+}}
405 // CHECK-NEXT:  |-CXXMethodDecl 0x{{.+}} <line:[[@LINE-122]]:5, col:11> col:9 j 'int ()' implicit_instantiation
406 // CHECK-NEXT:  `-FieldDecl 0x{{.+}} <line:[[@LINE-122]]:5, col:9> col:9 i 'int'
407 
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'
421 
422 // CHECK:       ClassTemplatePartialSpecializationDecl 0x{{.+}} <{{.+}}:[[@LINE-117]]:3, line:[[@LINE-115]]:3> line:[[@LINE-117]]:31 class TestClassTemplatePartial definition
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'
438 
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
444 
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
459 
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
465 
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
471 
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
486 
487 
488 // PR15220 dump instantiation only once
489 namespace testCanonicalTemplate {
490   class A {};
491 
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)'
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':'testCanonicalTemplate::A'
504 
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
511 
512   template<typename T1> class TestClassTemplate {
513     template<typename T2> friend class TestClassTemplate;
514   };
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 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
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 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> &&'
554 
555 
556   template<typename T1> class TestClassTemplate2;
557   template<typename T1> class TestClassTemplate2;
558   template<typename T1> class TestClassTemplate2 {
559   };
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
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> &&'
582 
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'
587 
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'
600 
601   struct S {
602       template<typename T> static const T TestVarTemplate; // declaration of a static data member template
603   };
604   template<typename T>
605   const T S::TestVarTemplate = { }; // definition of a static data member template
606 
607   void f()
608   {
609     int i = S::TestVarTemplate<int>;
610     int j = S::TestVarTemplate<int>;
611   }
612 
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':'const int' implicit_instantiation cinit
617   // CHECK-NEXT: | |-TemplateArgument type 'int'
618   // CHECK-NEXT: | | `-BuiltinType 0x{{.+}} 'int'
619   // CHECK-NEXT: | `-InitListExpr 0x{{.+}} <col:32, col:34> 'int':'int'
620   // CHECK-NEXT: `-VarTemplateSpecializationDecl 0x{{.+}} <line:[[@LINE-18]]:28, col:43> col:43 referenced TestVarTemplate 'const int':'const int' implicit_instantiation static
621   // CHECK-NEXT:   `-TemplateArgument type 'int'
622 
623   // CHECK:     VarTemplateSpecializationDecl 0x{{.+}} <{{.+}}:[[@LINE-21]]:28, col:43> col:43 referenced TestVarTemplate 'const int':'const int' implicit_instantiation static
624   // CHECK-NEXT:`-TemplateArgument type 'int'
625   // CHECK-NEXT:  `-BuiltinType 0x{{.+}} 'int'
626 
627   // CHECK:      VarTemplateDecl 0x{{.+}} parent 0x{{.+}} prev 0x{{.+}} <{{.+}}:[[@LINE-23]]:3, line:[[@LINE-22]]:34> col:14 TestVarTemplate
628   // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <line:[[@LINE-24]]:12, col:21> col:21 referenced typename depth 0 index 0 T
629   // CHECK-NEXT: |-VarDecl 0x{{.+}} parent 0x{{.+}} prev 0x{{.+}} <line:[[@LINE-24]]:3, col:34> col:14 TestVarTemplate 'const T' cinit
630   // CHECK-NEXT: | `-InitListExpr 0x{{.+}} <col:32, col:34> 'void'
631   // CHECK-NEXT: |-VarTemplateSpecialization 0x{{.+}} 'TestVarTemplate' 'const int':'const int'
632   // CHECK-NEXT: `-VarTemplateSpecialization 0x{{.+}} 'TestVarTemplate' 'const int':'const int'
633 
634   // CHECK:      VarTemplateSpecializationDecl 0x{{.+}} parent 0x{{.+}} prev 0x{{.+}} <{{.+}}:[[@LINE-29]]:3, col:34> col:14 referenced TestVarTemplate 'const int':'const int' implicit_instantiation cinit
635   // CHECK-NEXT: |-TemplateArgument type 'int'
636   // CHECK-NEXT: | `-BuiltinType 0x{{.+}} 'int'
637   // CHECK-NEXT: `-InitListExpr 0x{{.+}} <col:32, col:34> 'int':'int'
638 }
639 
640 template <class T>
641 class TestClassScopeFunctionSpecialization {
642   template<class U> void foo(U a) { }
643   template<> void foo<int>(int a) { }
644 };
645 // CHECK:      ClassScopeFunctionSpecializationDecl
646 // CHECK-NEXT:   CXXMethod{{.*}} foo 'void (int)'
647 // CHECK-NEXT:     ParmVarDecl
648 // CHECK-NEXT:     CompoundStmt
649 // CHECK-NEXT:   TemplateArgument{{.*}} 'int'
650 
651 namespace TestTemplateTypeParmDecl {
652   template<typename ... T, class U = int> void foo();
653 }
654 // CHECK:      NamespaceDecl{{.*}} TestTemplateTypeParmDecl
655 // CHECK-NEXT:   FunctionTemplateDecl
656 // CHECK-NEXT:     TemplateTypeParmDecl{{.*}} typename depth 0 index 0 ... T
657 // CHECK-NEXT:     TemplateTypeParmDecl{{.*}} class depth 0 index 1 U
658 // CHECK-NEXT:       TemplateArgument type 'int'
659 
660 namespace TestNonTypeTemplateParmDecl {
661   template<int I = 1, int ... J> void foo();
662 }
663 // CHECK:      NamespaceDecl{{.*}} TestNonTypeTemplateParmDecl
664 // CHECK-NEXT:   FunctionTemplateDecl
665 // CHECK-NEXT:     NonTypeTemplateParmDecl{{.*}} 'int' depth 0 index 0 I
666 // CHECK-NEXT:       TemplateArgument expr
667 // CHECK-NEXT:         IntegerLiteral{{.*}} 'int' 1
668 // CHECK-NEXT:     NonTypeTemplateParmDecl{{.*}} 'int' depth 0 index 1 ... J
669 
670 namespace TestTemplateTemplateParmDecl {
671   template<typename T> class A;
672   template <template <typename> class T = A, template <typename> class ... U> void foo();
673 }
674 // CHECK:      NamespaceDecl{{.*}} TestTemplateTemplateParmDecl
675 // CHECK:        FunctionTemplateDecl
676 // CHECK-NEXT:     TemplateTemplateParmDecl{{.*}} T
677 // CHECK-NEXT:       TemplateTypeParmDecl{{.*}} typename
678 // CHECK-NEXT:       TemplateArgument{{.*}} template A
679 // CHECK-NEXT:     TemplateTemplateParmDecl{{.*}} ... U
680 // CHECK-NEXT:       TemplateTypeParmDecl{{.*}} typename
681 
682 namespace TestTemplateArgument {
683   template<typename> class A { };
684   template<template<typename> class ...> class B { };
685   int foo();
686 
687   template<typename> class testType { };
688   template class testType<int>;
689   // CHECK:      ClassTemplateSpecializationDecl{{.*}} class testType
690   // CHECK:        TemplateArgument{{.*}} type 'int'
691 
692   template<int fp(void)> class testDecl { };
693   template class testDecl<foo>;
694   // CHECK:      ClassTemplateSpecializationDecl{{.*}} class testDecl
695   // CHECK:        TemplateArgument{{.*}} decl
696   // CHECK-NEXT:     Function{{.*}}foo
697 
698   template class testDecl<nullptr>;
699   // CHECK:      ClassTemplateSpecializationDecl{{.*}} class testDecl
700   // CHECK:        TemplateArgument{{.*}} nullptr
701 
702   template<int> class testIntegral { };
703   template class testIntegral<1>;
704   // CHECK:      ClassTemplateSpecializationDecl{{.*}} class testIntegral
705   // CHECK:        TemplateArgument{{.*}} integral 1
706 
707   template<template<typename> class> class testTemplate { };
708   template class testTemplate<A>;
709   // CHECK:      ClassTemplateSpecializationDecl{{.*}} class testTemplate
710   // CHECK:        TemplateArgument{{.*}} A
711 
712   template<template<typename> class ...T> class C {
713     B<T...> testTemplateExpansion;
714   };
715   // FIXME: Need TemplateSpecializationType dumping to test TemplateExpansion.
716 
717   template<int, int = 0> class testExpr;
718   template<int I> class testExpr<I> { };
719   // CHECK:      ClassTemplatePartialSpecializationDecl{{.*}} class testExpr
720   // CHECK:        TemplateArgument{{.*}} expr
721   // CHECK-NEXT:     DeclRefExpr{{.*}}I
722 
723   template<int, int ...> class testPack { };
724   template class testPack<0, 1, 2>;
725   // CHECK:      ClassTemplateSpecializationDecl{{.*}} class testPack
726   // CHECK:        TemplateArgument{{.*}} integral 0
727   // CHECK-NEXT:   TemplateArgument{{.*}} pack
728   // CHECK-NEXT:     TemplateArgument{{.*}} integral 1
729   // CHECK-NEXT:     TemplateArgument{{.*}} integral 2
730 }
731 
732 namespace testUsingDecl {
733   int i;
734 }
735 namespace TestUsingDecl {
736   using testUsingDecl::i;
737 }
738 // CHECK:      NamespaceDecl{{.*}} TestUsingDecl
739 // CHECK-NEXT:   UsingDecl{{.*}} testUsingDecl::i
740 // CHECK-NEXT:   UsingShadowDecl{{.*}} Var{{.*}} 'i' 'int'
741 
742 namespace testUnresolvedUsing {
743   class A { };
744   template<class T> class B {
745   public:
746     A a;
747   };
748   template<class T> class TestUnresolvedUsing : public B<T> {
749     using typename B<T>::a;
750     using B<T>::a;
751   };
752 }
753 // CHECK: CXXRecordDecl{{.*}} TestUnresolvedUsing
754 // CHECK:   UnresolvedUsingTypenameDecl{{.*}} B<T>::a
755 // CHECK:   UnresolvedUsingValueDecl{{.*}} B<T>::a
756 
757 namespace TestLinkageSpecDecl {
758   extern "C" void test1();
759   extern "C++" void test2();
760 }
761 // CHECK:      NamespaceDecl{{.*}} TestLinkageSpecDecl
762 // CHECK-NEXT:   LinkageSpecDecl{{.*}} C
763 // CHECK-NEXT:     FunctionDecl
764 // CHECK-NEXT:   LinkageSpecDecl{{.*}} C++
765 // CHECK-NEXT:     FunctionDecl
766 
767 class TestAccessSpecDecl {
768 public:
769 private:
770 protected:
771 };
772 // CHECK:      CXXRecordDecl{{.*}} class TestAccessSpecDecl
773 // CHECK:         CXXRecordDecl{{.*}} class TestAccessSpecDecl
774 // CHECK-NEXT:    AccessSpecDecl{{.*}} public
775 // CHECK-NEXT:    AccessSpecDecl{{.*}} private
776 // CHECK-NEXT:    AccessSpecDecl{{.*}} protected
777 
778 template<typename T> class TestFriendDecl {
779   friend int foo();
780   friend class A;
781   friend T;
782 };
783 // CHECK:      CXXRecord{{.*}} TestFriendDecl
784 // CHECK:        CXXRecord{{.*}} TestFriendDecl
785 // CHECK-NEXT:   FriendDecl
786 // CHECK-NEXT:     FunctionDecl{{.*}} foo
787 // CHECK-NEXT:   FriendDecl{{.*}} 'class A':'A'
788 // CHECK-NEXT:     CXXRecordDecl{{.*}} class A
789 // CHECK-NEXT:   FriendDecl{{.*}} 'T'
790 
791 namespace TestFileScopeAsmDecl {
792   asm("ret");
793 }
794 // CHECK:      NamespaceDecl{{.*}} TestFileScopeAsmDecl{{$}}
795 // CHECK:        FileScopeAsmDecl{{.*> .*$}}
796 // CHECK-NEXT:     StringLiteral
797 
798 namespace TestFriendDecl2 {
799   void f();
800   struct S {
801     friend void f();
802   };
803 }
804 // CHECK: NamespaceDecl [[TestFriendDecl2:0x.*]] <{{.*}}> {{.*}} TestFriendDecl2
805 // CHECK: |-FunctionDecl [[TestFriendDecl2_f:0x.*]] <{{.*}}> {{.*}} f 'void ()'
806 // CHECK: `-CXXRecordDecl {{.*}} struct S
807 // CHECK:   |-CXXRecordDecl {{.*}} struct S
808 // CHECK:   `-FriendDecl
809 // CHECK:     `-FunctionDecl {{.*}} parent [[TestFriendDecl2]] prev [[TestFriendDecl2_f]] <{{.*}}> {{.*}} f 'void ()'
810 
811 namespace Comment {
812   extern int Test;
813   /// Something here.
814   extern int Test;
815   extern int Test;
816 }
817 
818 // CHECK: VarDecl {{.*}} Test 'int' extern
819 // CHECK-NOT: FullComment
820 // CHECK: VarDecl {{.*}} Test 'int' extern
821 // CHECK: `-FullComment
822 // CHECK:   `-ParagraphComment
823 // CHECK:       `-TextComment
824 // CHECK: VarDecl {{.*}} Test 'int' extern
825 // CHECK-NOT: FullComment
826 
827 namespace TestConstexprVariableTemplateWithInitializer {
828   template<typename T> constexpr T foo{};
829   // CHECK:      VarTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-1]]:3, col:40> col:36 foo
830   // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <col:12, col:21> col:21 referenced typename depth 0 index 0 T
831   // CHECK-NEXT: `-VarDecl 0x{{.+}} <col:24, col:40> col:36 foo 'const T' constexpr listinit
832   // CHECK-NEXT:  `-InitListExpr 0x{{.+}} <col:39, col:40> 'void'
833 
834   template<typename T> constexpr int val{42};
835   // CHECK:      VarTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-1]]:3, col:44> col:38 val
836   // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <col:12, col:21> col:21 typename depth 0 index 0 T
837   // CHECK-NEXT: `-VarDecl 0x{{.+}} <col:24, col:44> col:38 val 'const int' constexpr listinit
838   // CHECK-NEXT:  |-value: Int 42
839   // CHECK-NEXT:  `-InitListExpr 0x{{.+}} <col:41, col:44> 'int'
840 
841   template <typename _Tp>
842   struct in_place_type_t {
843     explicit in_place_type_t() = default;
844   };
845 
846   template <typename _Tp>
847   inline constexpr in_place_type_t<_Tp> in_place_type{};
848   // CHECK:     -VarTemplateDecl 0x{{.+}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:55> col:41 in_place_type
849   // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <line:[[@LINE-3]]:13, col:22> col:22 referenced typename depth 0 index 0 _Tp
850   // CHECK-NEXT: `-VarDecl 0x{{.+}} <line:[[@LINE-3]]:3, col:55> col:41 in_place_type 'const in_place_type_t<_Tp>':'const in_place_type_t<_Tp>' inline constexpr listinit
851   // CHECK-NEXT:  `-InitListExpr 0x{{.+}} <col:54, col:55> 'void'
852 
853   template <typename T> constexpr T call_init(0);
854   // CHECK:     -VarTemplateDecl 0x{{.+}} <line:[[@LINE-1]]:3, col:48> col:37 call_init
855   // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <col:13, col:22> col:22 referenced typename depth 0 index 0 T
856   // CHECK-NEXT: `-VarDecl 0x{{.+}} <col:25, col:48> col:37 call_init 'const T' constexpr callinit
857   // CHECK-NEXT:  `-ParenListExpr 0x{{.+}} <col:46, col:48> 'NULL TYPE'
858   // CHECK-NEXT:   `-IntegerLiteral 0x{{.+}} <col:47> 'int' 0
859 
860 }
861