• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 { };
foo()28   A foo() {
29     A TestVarDeclNRVO;
30     return TestVarDeclNRVO;
31   }
32 }
33 // CHECK: VarDecl{{.*}} TestVarDeclNRVO 'testVarDeclNRVO::A' nrvo
34 
35 void testParmVarDeclInit(int TestParmVarDeclInit = 0);
36 // CHECK:      ParmVarDecl{{.*}} TestParmVarDeclInit 'int'
37 // CHECK-NEXT:   IntegerLiteral{{.*}}
38 
39 namespace TestNamespaceDecl {
40   int i;
41 }
42 // CHECK:      NamespaceDecl{{.*}} TestNamespaceDecl
43 // CHECK-NEXT:   VarDecl
44 
45 namespace TestNamespaceDecl {
46   int j;
47 }
48 // CHECK:      NamespaceDecl{{.*}} TestNamespaceDecl
49 // CHECK-NEXT:   original Namespace
50 // CHECK-NEXT:   VarDecl
51 
52 inline namespace TestNamespaceDeclInline {
53 }
54 // CHECK:      NamespaceDecl{{.*}} TestNamespaceDeclInline inline
55 
56 namespace testUsingDirectiveDecl {
57   namespace A {
58   }
59 }
60 namespace TestUsingDirectiveDecl {
61   using namespace testUsingDirectiveDecl::A;
62 }
63 // CHECK:      NamespaceDecl{{.*}} TestUsingDirectiveDecl
64 // CHECK-NEXT:   UsingDirectiveDecl{{.*}} Namespace{{.*}} 'A'
65 
66 namespace testNamespaceAlias {
67   namespace A {
68   }
69 }
70 namespace TestNamespaceAlias = testNamespaceAlias::A;
71 // CHECK:      NamespaceAliasDecl{{.*}} TestNamespaceAlias
72 // CHECK-NEXT:   Namespace{{.*}} 'A'
73 
74 using TestTypeAliasDecl = int;
75 // CHECK: TypeAliasDecl{{.*}} TestTypeAliasDecl 'int'
76 
77 namespace testTypeAliasTemplateDecl {
78   template<typename T> class A;
79   template<typename T> using TestTypeAliasTemplateDecl = A<T>;
80 }
81 // CHECK:      TypeAliasTemplateDecl{{.*}} TestTypeAliasTemplateDecl
82 // CHECK-NEXT:   TemplateTypeParmDecl
83 // CHECK-NEXT:   TypeAliasDecl{{.*}} TestTypeAliasTemplateDecl 'A<T>'
84 
85 namespace testCXXRecordDecl {
86   class TestEmpty {};
87 // CHECK:      CXXRecordDecl{{.*}} class TestEmpty
88 // 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
89 // CHECK-NEXT:     DefaultConstructor exists trivial constexpr
90 // CHECK-NEXT:     CopyConstructor simple trivial has_const_param
91 // CHECK-NEXT:     MoveConstructor exists simple trivial
92 // CHECK-NEXT:     CopyAssignment simple trivial has_const_param
93 // CHECK-NEXT:     MoveAssignment exists simple trivial
94 // CHECK-NEXT:     Destructor simple irrelevant trivial
95 
96   class A { };
97   class B { };
98   class TestCXXRecordDecl : virtual A, public B {
99     int i;
100   };
101 }
102 // CHECK:      CXXRecordDecl{{.*}} class TestCXXRecordDecl
103 // CHECK-NEXT:   DefinitionData{{$}}
104 // CHECK-NEXT:     DefaultConstructor exists non_trivial
105 // CHECK-NEXT:     CopyConstructor simple non_trivial has_const_param
106 // CHECK-NEXT:     MoveConstructor exists simple non_trivial
107 // CHECK-NEXT:     CopyAssignment simple non_trivial has_const_param
108 // CHECK-NEXT:     MoveAssignment exists simple non_trivial
109 // CHECK-NEXT:     Destructor simple irrelevant trivial
110 // CHECK-NEXT:   virtual private 'testCXXRecordDecl::A'
111 // CHECK-NEXT:   public 'testCXXRecordDecl::B'
112 // CHECK-NEXT:   CXXRecordDecl{{.*}} class TestCXXRecordDecl
113 // CHECK-NEXT:   FieldDecl
114 
115 template<class...T>
116 class TestCXXRecordDeclPack : public T... {
117 };
118 // CHECK:      CXXRecordDecl{{.*}} class TestCXXRecordDeclPack
119 // CHECK:        public 'T'...
120 // CHECK-NEXT:   CXXRecordDecl{{.*}} class TestCXXRecordDeclPack
121 
122 thread_local int TestThreadLocalInt;
123 // CHECK: TestThreadLocalInt {{.*}} tls_dynamic
124 
125 class testCXXMethodDecl {
126   virtual void TestCXXMethodDeclPure() = 0;
127   void TestCXXMethodDeclDelete() = delete;
128   void TestCXXMethodDeclThrow() throw();
129   void TestCXXMethodDeclThrowType() throw(int);
130 };
131 // CHECK: CXXMethodDecl{{.*}} TestCXXMethodDeclPure 'void ()' virtual pure
132 // CHECK: CXXMethodDecl{{.*}} TestCXXMethodDeclDelete 'void ()' delete
133 // CHECK: CXXMethodDecl{{.*}} TestCXXMethodDeclThrow 'void () throw()'
134 // CHECK: CXXMethodDecl{{.*}} TestCXXMethodDeclThrowType 'void () throw(int)'
135 
136 namespace testCXXConstructorDecl {
137   class A { };
138   class TestCXXConstructorDecl : public A {
139     int I;
TestCXXConstructorDecl(A & a,int i)140     TestCXXConstructorDecl(A &a, int i) : A(a), I(i) { }
TestCXXConstructorDecl(A & a)141     TestCXXConstructorDecl(A &a) : TestCXXConstructorDecl(a, 0) { }
142   };
143 }
144 // CHECK:      CXXConstructorDecl{{.*}} TestCXXConstructorDecl 'void {{.*}}'
145 // CHECK-NEXT:   ParmVarDecl{{.*}} a
146 // CHECK-NEXT:   ParmVarDecl{{.*}} i
147 // CHECK-NEXT:   CXXCtorInitializer{{.*}}A
148 // CHECK-NEXT:     Expr
149 // CHECK:        CXXCtorInitializer{{.*}}I
150 // CHECK-NEXT:     Expr
151 // CHECK:        CompoundStmt
152 // CHECK:      CXXConstructorDecl{{.*}} TestCXXConstructorDecl 'void {{.*}}'
153 // CHECK-NEXT:   ParmVarDecl{{.*}} a
154 // CHECK-NEXT:   CXXCtorInitializer{{.*}}TestCXXConstructorDecl
155 // CHECK-NEXT:     CXXConstructExpr{{.*}}TestCXXConstructorDecl
156 
157 class TestCXXDestructorDecl {
~TestCXXDestructorDecl()158   ~TestCXXDestructorDecl() { }
159 };
160 // CHECK:      CXXDestructorDecl{{.*}} ~TestCXXDestructorDecl 'void () noexcept'
161 // CHECK-NEXT:   CompoundStmt
162 
163 // Test that the range of a defaulted members is computed correctly.
164 class TestMemberRanges {
165 public:
166   TestMemberRanges() = default;
167   TestMemberRanges(const TestMemberRanges &Other) = default;
168   TestMemberRanges(TestMemberRanges &&Other) = default;
169   ~TestMemberRanges() = default;
170   TestMemberRanges &operator=(const TestMemberRanges &Other) = default;
171   TestMemberRanges &operator=(TestMemberRanges &&Other) = default;
172 };
SomeFunction()173 void SomeFunction() {
174   TestMemberRanges A;
175   TestMemberRanges B(A);
176   B = A;
177   A = static_cast<TestMemberRanges &&>(B);
178   TestMemberRanges C(static_cast<TestMemberRanges &&>(A));
179 }
180 // CHECK:      CXXConstructorDecl{{.*}} <line:{{.*}}:3, col:30>
181 // CHECK:      CXXConstructorDecl{{.*}} <line:{{.*}}:3, col:59>
182 // CHECK:      CXXConstructorDecl{{.*}} <line:{{.*}}:3, col:54>
183 // CHECK:      CXXDestructorDecl{{.*}} <line:{{.*}}:3, col:31>
184 // CHECK:      CXXMethodDecl{{.*}} <line:{{.*}}:3, col:70>
185 // CHECK:      CXXMethodDecl{{.*}} <line:{{.*}}:3, col:65>
186 
187 class TestCXXConversionDecl {
operator int()188   operator int() { return 0; }
189 };
190 // CHECK:      CXXConversionDecl{{.*}} operator int 'int ()'
191 // CHECK-NEXT:   CompoundStmt
192 
193 namespace TestStaticAssertDecl {
194   static_assert(true, "msg");
195 }
196 // CHECK:      NamespaceDecl{{.*}} TestStaticAssertDecl
197 // CHECK-NEXT:   StaticAssertDecl{{.*> .*$}}
198 // CHECK-NEXT:     CXXBoolLiteralExpr
199 // CHECK-NEXT:     StringLiteral
200 
201 namespace testFunctionTemplateDecl {
202   class A { };
203   class B { };
204   class C { };
205   class D { };
TestFunctionTemplate(T)206   template<typename T> void TestFunctionTemplate(T) { }
207 
208   // implicit instantiation
bar(A a)209   void bar(A a) { TestFunctionTemplate(a); }
210 
211   // explicit specialization
212   template<> void TestFunctionTemplate(B);
213 
214   // explicit instantiation declaration
215   extern template void TestFunctionTemplate(C);
216 
217   // explicit instantiation definition
218   template void TestFunctionTemplate(D);
219 }
220   // CHECK:       FunctionTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-14]]:3, col:55> col:29 TestFunctionTemplate
221   // CHECK-NEXT:  |-TemplateTypeParmDecl 0x{{.+}} <col:12, col:21> col:21 referenced typename depth 0 index 0 T
222   // CHECK-NEXT:  |-FunctionDecl 0x{{.+}} <col:24, col:55> col:29 TestFunctionTemplate 'void (T)'
223   // CHECK-NEXT:  | |-ParmVarDecl 0x{{.+}} <col:50> col:51 'T'
224   // CHECK-NEXT:  | `-CompoundStmt 0x{{.+}} <col:53, col:55>
225   // CHECK-NEXT:  |-FunctionDecl 0x{{.+}} <col:24, col:55> col:29 used TestFunctionTemplate 'void (testFunctionTemplateDecl::A)'
226   // CHECK-NEXT:  | |-TemplateArgument type 'testFunctionTemplateDecl::A'
227   // CHECK-NEXT:  | | `-RecordType 0{{.+}} 'testFunctionTemplateDecl::A'
228   // CHECK-NEXT:  | |   `-CXXRecord 0x{{.+}} 'A'
229   // CHECK-NEXT:  | |-ParmVarDecl 0x{{.+}} <col:50> col:51 'testFunctionTemplateDecl::A':'testFunctionTemplateDecl::A'
230   // CHECK-NEXT:  | `-CompoundStmt 0x{{.+}} <col:53, col:55>
231   // CHECK-NEXT:  |-Function 0x{{.+}} 'TestFunctionTemplate' 'void (testFunctionTemplateDecl::B)'
232   // CHECK-NEXT:  |-FunctionDecl 0x{{.+}} <col:24, col:55> col:29 TestFunctionTemplate 'void (testFunctionTemplateDecl::C)'
233   // CHECK-NEXT:  | |-TemplateArgument type 'testFunctionTemplateDecl::C'
234   // CHECK-NEXT:  | | `-RecordType 0{{.+}} 'testFunctionTemplateDecl::C'
235   // CHECK-NEXT:  | |   `-CXXRecord 0x{{.+}} 'C'
236   // CHECK-NEXT:  | `-ParmVarDecl 0x{{.+}} <col:50> col:51 'testFunctionTemplateDecl::C':'testFunctionTemplateDecl::C'
237   // CHECK-NEXT:  `-FunctionDecl 0x{{.+}} <col:24, col:55> col:29 TestFunctionTemplate 'void (testFunctionTemplateDecl::D)'
238   // CHECK-NEXT:    |-TemplateArgument type 'testFunctionTemplateDecl::D'
239   // CHECK-NEXT:    | `-RecordType 0{{.+}} 'testFunctionTemplateDecl::D'
240   // CHECK-NEXT:    |   `-CXXRecord 0x{{.+}} 'D'
241   // CHECK-NEXT:    |-ParmVarDecl 0x{{.+}} <col:50> col:51 'testFunctionTemplateDecl::D':'testFunctionTemplateDecl::D'
242   // CHECK-NEXT:    `-CompoundStmt 0x{{.+}} <col:53, col:55>
243 
244   // CHECK:       FunctionDecl 0x{{.+}} prev 0x{{.+}} <{{.+}}:[[@LINE-32]]:3, col:41> col:19 TestFunctionTemplate 'void (testFunctionTemplateDecl::B)'
245   // CHECK-NEXT:  |-TemplateArgument type 'testFunctionTemplateDecl::B'
246   // CHECK-NEXT:  | `-RecordType 0{{.+}} 'testFunctionTemplateDecl::B'
247   // CHECK-NEXT:  |   `-CXXRecord 0x{{.+}} 'B'
248   // CHECK-NEXT:  `-ParmVarDecl 0x{{.+}} <col:40> col:41 'testFunctionTemplateDecl::B'
249 
250 
251 namespace testClassTemplateDecl {
252   class A { };
253   class B { };
254   class C { };
255   class D { };
256 
257   template<typename T> class TestClassTemplate {
258   public:
259     TestClassTemplate();
260     ~TestClassTemplate();
261     int j();
262     int i;
263   };
264 
265   // implicit instantiation
266   TestClassTemplate<A> a;
267 
268   // explicit specialization
269   template<> class TestClassTemplate<B> {
270     int j;
271   };
272 
273   // explicit instantiation declaration
274   extern template class TestClassTemplate<C>;
275 
276   // explicit instantiation definition
277   template class TestClassTemplate<D>;
278 
279   // partial explicit specialization
280   template<typename T1, typename T2> class TestClassTemplatePartial {
281     int i;
282   };
283   template<typename T1> class TestClassTemplatePartial<T1, A> {
284     int j;
285   };
286 
287   template<typename T = int> struct TestTemplateDefaultType;
288   template<typename T> struct TestTemplateDefaultType { };
289 
290   template<int I = 42> struct TestTemplateDefaultNonType;
291   template<int I> struct TestTemplateDefaultNonType { };
292 
293   template<template<typename> class TT = TestClassTemplate> struct TestTemplateTemplateDefaultType;
294   template<template<typename> class TT> struct TestTemplateTemplateDefaultType { };
295 }
296 
297 // CHECK:       ClassTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-40]]:3, line:[[@LINE-34]]:3> line:[[@LINE-40]]:30 TestClassTemplate
298 // CHECK-NEXT:  |-TemplateTypeParmDecl 0x{{.+}} <col:12, col:21> col:21 typename depth 0 index 0 T
299 // CHECK-NEXT:  |-CXXRecordDecl 0x{{.+}} <col:24, line:[[@LINE-36]]:3> line:[[@LINE-42]]:30 class TestClassTemplate definition
300 // CHECK-NEXT:  | |-DefinitionData standard_layout has_user_declared_ctor can_const_default_init
301 // CHECK-NEXT:  | | |-DefaultConstructor exists non_trivial user_provided
302 // CHECK-NEXT:  | | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param
303 // CHECK-NEXT:  | | |-MoveConstructor
304 // CHECK-NEXT:  | | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param
305 // CHECK-NEXT:  | | |-MoveAssignment
306 // CHECK-NEXT:  | | `-Destructor non_trivial user_declared
307 // CHECK-NEXT:  | |-CXXRecordDecl 0x{{.+}} <col:24, col:30> col:30 implicit referenced class TestClassTemplate
308 // CHECK-NEXT:  | |-AccessSpecDecl 0x{{.+}} <line:[[@LINE-50]]:3, col:9> col:3 public
309 // CHECK-NEXT:  | |-CXXConstructorDecl 0x{{.+}} <line:[[@LINE-50]]:5, col:23> col:5 TestClassTemplate<T> 'void ()'
310 // CHECK-NEXT:  | |-CXXDestructorDecl 0x{{.+}} <line:[[@LINE-50]]:5, col:24> col:5 ~TestClassTemplate<T> 'void ()'
311 // CHECK-NEXT:  | |-CXXMethodDecl 0x{{.+}} <line:[[@LINE-50]]:5, col:11> col:9 j 'int ()'
312 // CHECK-NEXT:  | `-FieldDecl 0x{{.+}} <line:[[@LINE-50]]:5, col:9> col:9 i 'int'
313 // CHECK-NEXT:  |-ClassTemplateSpecializationDecl 0x{{.+}} <line:[[@LINE-56]]:3, line:[[@LINE-50]]:3> line:[[@LINE-56]]:30 class TestClassTemplate definition
314 // CHECK-NEXT:  | |-DefinitionData standard_layout has_user_declared_ctor can_const_default_init
315 // CHECK-NEXT:  | | |-DefaultConstructor exists non_trivial user_provided
316 // CHECK-NEXT:  | | |-CopyConstructor simple trivial has_const_param implicit_has_const_param
317 // CHECK-NEXT:  | | |-MoveConstructor
318 // CHECK-NEXT:  | | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param
319 // CHECK-NEXT:  | | |-MoveAssignment
320 // CHECK-NEXT:  | | `-Destructor non_trivial user_declared
321 // CHECK-NEXT:  | |-TemplateArgument type 'testClassTemplateDecl::A'
322 // CHECK-NEXT:  | | `-RecordType 0{{.+}} 'testClassTemplateDecl::A'
323 // CHECK-NEXT:  | |   `-CXXRecord 0x{{.+}} 'A'
324 // CHECK-NEXT:  | |-CXXRecordDecl 0x{{.+}} prev 0x{{.+}} <col:24, col:30> col:30 implicit class TestClassTemplate
325 // CHECK-NEXT:  | |-AccessSpecDecl 0x{{.+}} <line:[[@LINE-67]]:3, col:9> col:3 public
326 // CHECK-NEXT:  | |-CXXConstructorDecl 0x{{.+}} <line:[[@LINE-67]]:5, col:23> col:5 used TestClassTemplate 'void ()'
327 // CHECK-NEXT:  | |-CXXDestructorDecl 0x{{.+}} <line:[[@LINE-67]]:5, col:24> col:5 used ~TestClassTemplate 'void () noexcept'
328 // CHECK-NEXT:  | |-CXXMethodDecl 0x{{.+}} <line:[[@LINE-67]]:5, col:11> col:9 j 'int ()'
329 // CHECK-NEXT:  | |-FieldDecl 0x{{.+}} <line:[[@LINE-67]]:5, col:9> col:9 i 'int'
330 // CHECK-NEXT:  | `-CXXConstructorDecl 0x{{.+}} <line:[[@LINE-73]]:30> col:30 implicit constexpr TestClassTemplate 'void (const testClassTemplateDecl::TestClassTemplate<testClassTemplateDecl::A> &)' inline default trivial noexcept-unevaluated 0x{{.+}}
331 // CHECK-NEXT:  |   `-ParmVarDecl 0x{{.+}} <col:30> col:30 'const testClassTemplateDecl::TestClassTemplate<testClassTemplateDecl::A> &'
332 // CHECK-NEXT:  |-ClassTemplateSpecialization 0x{{.+}} 'TestClassTemplate'
333 // CHECK-NEXT:  |-ClassTemplateSpecialization 0x{{.+}} 'TestClassTemplate'
334 // CHECK-NEXT:  `-ClassTemplateSpecialization 0x{{.+}} 'TestClassTemplate'
335 
336 // CHECK:       ClassTemplateSpecializationDecl 0x{{.+}} <{{.+}}:[[@LINE-67]]:3, line:[[@LINE-65]]:3> line:[[@LINE-67]]:20 class TestClassTemplate definition
337 // CHECK-NEXT:  |-DefinitionData pass_in_registers standard_layout trivially_copyable trivial literal
338 // CHECK-NEXT:  | |-DefaultConstructor exists trivial needs_implicit
339 // CHECK-NEXT:  | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param
340 // CHECK-NEXT:  | |-MoveConstructor exists simple trivial needs_implicit
341 // CHECK-NEXT:  | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param
342 // CHECK-NEXT:  | |-MoveAssignment exists simple trivial needs_implicit
343 // CHECK-NEXT:  | `-Destructor simple irrelevant trivial needs_implicit
344 // CHECK-NEXT:  |-TemplateArgument type 'testClassTemplateDecl::B'
345 // CHECK-NEXT:  | `-RecordType 0{{.+}} 'testClassTemplateDecl::B'
346 // CHECK-NEXT:  |   `-CXXRecord 0x{{.+}} 'B'
347 // CHECK-NEXT:  |-CXXRecordDecl 0x{{.+}} <col:14, col:20> col:20 implicit class TestClassTemplate
348 // CHECK-NEXT:  `-FieldDecl 0x{{.+}} <line:[[@LINE-78]]:5, col:9> col:9 j 'int'
349 
350 // CHECK:       ClassTemplateSpecializationDecl 0x{{.+}} <{{.+}}:{{.*}}:3, col:44> col:25 class TestClassTemplate definition
351 // CHECK-NEXT:  |-DefinitionData standard_layout has_user_declared_ctor can_const_default_init
352 // CHECK-NEXT:  | |-DefaultConstructor exists non_trivial user_provided
353 // CHECK-NEXT:  | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param
354 // CHECK-NEXT:  | |-MoveConstructor
355 // CHECK-NEXT:  | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param
356 // CHECK-NEXT:  | |-MoveAssignment
357 // CHECK-NEXT:  | `-Destructor non_trivial user_declared
358 // CHECK-NEXT:  |-TemplateArgument type 'testClassTemplateDecl::C'
359 // CHECK-NEXT:  | `-RecordType 0{{.+}} 'testClassTemplateDecl::C'
360 // CHECK-NEXT:  |   `-CXXRecord 0x{{.+}} 'C'
361 // CHECK-NEXT:  |-CXXRecordDecl 0x{{.+}} prev 0x{{.+}} <line:[[@LINE-104]]:24, col:30> col:30 implicit class TestClassTemplate
362 // CHECK-NEXT:  |-AccessSpecDecl 0x{{.+}} <line:[[@LINE-104]]:3, col:9> col:3 public
363 // CHECK-NEXT:  |-CXXConstructorDecl 0x{{.+}} <line:[[@LINE-104]]:5, col:23> col:5 TestClassTemplate 'void ()'
364 // CHECK-NEXT:  |-CXXDestructorDecl 0x{{.+}} <line:[[@LINE-104]]:5, col:24> col:5 ~TestClassTemplate 'void ()' noexcept-unevaluated 0x{{.+}}
365 // CHECK-NEXT:  |-CXXMethodDecl 0x{{.+}} <line:[[@LINE-104]]:5, col:11> col:9 j 'int ()'
366 // CHECK-NEXT:  `-FieldDecl 0x{{.+}} <line:[[@LINE-104]]:5, col:9> col:9 i 'int'
367 
368 // CHECK:       ClassTemplateSpecializationDecl 0x{{.+}} <{{.+}}:[[@LINE-91]]:3, col:37> col:18 class TestClassTemplate definition
369 // CHECK-NEXT:  |-DefinitionData standard_layout has_user_declared_ctor can_const_default_init
370 // CHECK-NEXT:  | |-DefaultConstructor exists non_trivial user_provided
371 // CHECK-NEXT:  | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param
372 // CHECK-NEXT:  | |-MoveConstructor
373 // CHECK-NEXT:  | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param
374 // CHECK-NEXT:  | |-MoveAssignment
375 // CHECK-NEXT:  | `-Destructor non_trivial user_declared
376 // CHECK-NEXT:  |-TemplateArgument type 'testClassTemplateDecl::D'
377 // CHECK-NEXT:  | `-RecordType 0{{.+}} 'testClassTemplateDecl::D'
378 // CHECK-NEXT:  |   `-CXXRecord 0x{{.+}} 'D'
379 // CHECK-NEXT:  |-CXXRecordDecl 0x{{.+}} prev 0x{{.+}} <line:[[@LINE-122]]:24, col:30> col:30 implicit class TestClassTemplate
380 // CHECK-NEXT:  |-AccessSpecDecl 0x{{.+}} <line:[[@LINE-122]]:3, col:9> col:3 public
381 // CHECK-NEXT:  |-CXXConstructorDecl 0x{{.+}} <line:[[@LINE-122]]:5, col:23> col:5 TestClassTemplate 'void ()'
382 // CHECK-NEXT:  |-CXXDestructorDecl 0x{{.+}} <line:[[@LINE-122]]:5, col:24> col:5 ~TestClassTemplate 'void ()' noexcept-unevaluated 0x{{.+}}
383 // CHECK-NEXT:  |-CXXMethodDecl 0x{{.+}} <line:[[@LINE-122]]:5, col:11> col:9 j 'int ()'
384 // CHECK-NEXT:  `-FieldDecl 0x{{.+}} <line:[[@LINE-122]]:5, col:9> col:9 i 'int'
385 
386 // CHECK:      ClassTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-106]]:3, line:[[@LINE-104]]:3> line:[[@LINE-106]]:44 TestClassTemplatePartial
387 // CHECK-NEXT:  |-TemplateTypeParmDecl 0x{{.+}} <col:12, col:21> col:21 typename depth 0 index 0 T1
388 // CHECK-NEXT:  |-TemplateTypeParmDecl 0x{{.+}} <col:25, col:34> col:34 typename depth 0 index 1 T2
389 // CHECK-NEXT:  `-CXXRecordDecl 0x{{.+}} <col:38, line:[[@LINE-107]]:3> line:[[@LINE-109]]:44 class TestClassTemplatePartial definition
390 // CHECK-NEXT:    |-DefinitionData standard_layout trivially_copyable trivial literal
391 // CHECK-NEXT:    | |-DefaultConstructor exists trivial needs_implicit
392 // CHECK-NEXT:    | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param
393 // CHECK-NEXT:    | |-MoveConstructor exists simple trivial needs_implicit
394 // CHECK-NEXT:    | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param
395 // CHECK-NEXT:    | |-MoveAssignment exists simple trivial needs_implicit
396 // CHECK-NEXT:    | `-Destructor simple irrelevant trivial needs_implicit
397 // CHECK-NEXT:    |-CXXRecordDecl 0x{{.+}} <col:38, col:44> col:44 implicit class TestClassTemplatePartial
398 // CHECK-NEXT:    `-FieldDecl 0x{{.+}} <line:[[@LINE-117]]:5, col:9> col:9 i 'int'
399 
400 // CHECK:       ClassTemplatePartialSpecializationDecl 0x{{.+}} <{{.+}}:[[@LINE-117]]:3, line:[[@LINE-115]]:3> line:[[@LINE-117]]:31 class TestClassTemplatePartial definition
401 // CHECK-NEXT:  |-DefinitionData standard_layout trivially_copyable trivial literal
402 // CHECK-NEXT:  | |-DefaultConstructor exists trivial needs_implicit
403 // CHECK-NEXT:  | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param
404 // CHECK-NEXT:  | |-MoveConstructor exists simple trivial needs_implicit
405 // CHECK-NEXT:  | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param
406 // CHECK-NEXT:  | |-MoveAssignment exists simple trivial needs_implicit
407 // CHECK-NEXT:  | `-Destructor simple irrelevant trivial needs_implicit
408 // CHECK-NEXT:  |-TemplateArgument type 'type-parameter-0-0'
409 // CHECK-NEXT:  | `-TemplateTypeParmType 0x{{.+}} 'type-parameter-0-0' dependent depth 0 index 0
410 // CHECK-NEXT:  |-TemplateArgument type 'testClassTemplateDecl::A'
411 // CHECK-NEXT:  | `-RecordType 0x{{.+}} 'testClassTemplateDecl::A'
412 // CHECK-NEXT:  |   `-CXXRecord 0x{{.+}} 'A'
413 // CHECK-NEXT:  |-TemplateTypeParmDecl 0x{{.+}} <col:12, col:21> col:21 referenced typename depth 0 index 0 T1
414 // CHECK-NEXT:  |-CXXRecordDecl 0x{{.+}} <col:25, col:31> col:31 implicit class TestClassTemplatePartial
415 // CHECK-NEXT:  `-FieldDecl 0x{{.+}} <line:[[@LINE-131]]:5, col:9> col:9 j 'int'
416 
417 // CHECK:       ClassTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-130]]:3, col:37> col:37 TestTemplateDefaultType
418 // CHECK-NEXT:  |-TemplateTypeParmDecl 0x{{.+}} <col:12, col:25> col:21 typename depth 0 index 0 T
419 // CHECK-NEXT:  | `-TemplateArgument type 'int'
420 // CHECK-NEXT:  |   `-BuiltinType 0x{{.+}} 'int'
421 // CHECK-NEXT:  `-CXXRecordDecl 0x{{.+}} <col:30, col:37> col:37 struct TestTemplateDefaultType
422 
423 // CHECK:       ClassTemplateDecl 0x{{.+}} prev 0x{{.+}} <{{.+}}:[[@LINE-135]]:3, col:57> col:31 TestTemplateDefaultType
424 // CHECK-NEXT:  |-TemplateTypeParmDecl 0x{{.+}} <col:12, col:21> col:21 typename depth 0 index 0 T
425 // CHECK-NEXT:  | `-TemplateArgument type 'int'
426 // CHECK-NEXT:  |   |-inherited from TemplateTypeParm 0x{{.+}} 'T'
427 // CHECK-NEXT:  |   `-BuiltinType 0x{{.+}} 'int'
428 // CHECK-NEXT:  `-CXXRecordDecl 0x{{.+}} prev 0x{{.+}} <col:24, col:57> col:31 struct TestTemplateDefaultType definition
429 // CHECK-NEXT:    |-DefinitionData empty aggregate standard_layout trivially_copyable pod trivial literal has_constexpr_non_copy_move_ctor can_const_default_init
430 // CHECK-NEXT:    | |-DefaultConstructor exists trivial constexpr needs_implicit defaulted_is_constexpr
431 // CHECK-NEXT:    | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param
432 // CHECK-NEXT:    | |-MoveConstructor exists simple trivial needs_implicit
433 // CHECK-NEXT:    | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param
434 // CHECK-NEXT:    | |-MoveAssignment exists simple trivial needs_implicit
435 // CHECK-NEXT:    | `-Destructor simple irrelevant trivial needs_implicit
436 // CHECK-NEXT:    `-CXXRecordDecl 0x{{.+}} <col:24, col:31> col:31 implicit struct TestTemplateDefaultType
437 
438 // CHECK:       ClassTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-148]]:3, col:31> col:31 TestTemplateDefaultNonType
439 // CHECK-NEXT:  |-NonTypeTemplateParmDecl 0x{{.+}} <col:12, col:20> col:16 'int' depth 0 index 0 I
440 // CHECK-NEXT:  | `-TemplateArgument expr
441 // CHECK-NEXT:  |   `-ConstantExpr 0x{{.+}} <col:20> 'int'
442 // CHECK-NEXT:  |     |-value: Int 42
443 // CHECK-NEXT:  |     `-IntegerLiteral 0x{{.+}} <col:20> 'int' 42
444 // CHECK-NEXT:  `-CXXRecordDecl 0x{{.+}} <col:24, col:31> col:31 struct TestTemplateDefaultNonType
445 
446 // CHECK:       ClassTemplateDecl 0x{{.+}} <{{.+}}:{{.*}}:3, col:68> col:68 TestTemplateTemplateDefaultType
447 // CHECK-NEXT:  |-TemplateTemplateParmDecl 0x{{.+}} <col:12, col:42> col:37 depth 0 index 0 TT
448 // CHECK-NEXT:  | |-TemplateTypeParmDecl 0x{{.+}} <col:21> col:29 typename depth 1 index 0
449 // CHECK-NEXT:  | `-TemplateArgument <col:42> template TestClassTemplate
450 // CHECK-NEXT:  `-CXXRecordDecl 0x{{.+}} <col:61, col:68> col:68 struct TestTemplateTemplateDefaultType
451 
452 // CHECK:       ClassTemplateDecl 0x{{.+}} prev 0x{{.+}} <{{.+}}:{{.*}}:3, col:82> col:48 TestTemplateTemplateDefaultType
453 // CHECK-NEXT:  |-TemplateTemplateParmDecl 0x{{.+}} <col:12, col:37> col:37 depth 0 index 0 TT
454 // CHECK-NEXT:  | |-TemplateTypeParmDecl 0x{{.+}} <col:21> col:29 typename depth 1 index 0
455 // CHECK-NEXT:  | `-TemplateArgument <line:{{.*}}:42> template TestClassTemplate
456 // CHECK-NEXT:  |   `-inherited from TemplateTemplateParm 0x{{.+}} 'TT'
457 // CHECK-NEXT:  `-CXXRecordDecl 0x{{.+}} prev 0x{{.+}} <line:{{.*}}:41, col:82> col:48 struct TestTemplateTemplateDefaultType definition
458 // CHECK-NEXT:    |-DefinitionData empty aggregate standard_layout trivially_copyable pod trivial literal has_constexpr_non_copy_move_ctor can_const_default_init
459 // CHECK-NEXT:    | |-DefaultConstructor exists trivial constexpr needs_implicit defaulted_is_constexpr
460 // CHECK-NEXT:    | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param
461 // CHECK-NEXT:    | |-MoveConstructor exists simple trivial needs_implicit
462 // CHECK-NEXT:    | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param
463 // CHECK-NEXT:    | |-MoveAssignment exists simple trivial needs_implicit
464 // CHECK-NEXT:    | `-Destructor simple irrelevant trivial needs_implicit
465 // CHECK-NEXT:    `-CXXRecordDecl 0x{{.+}} <col:41, col:48> col:48 implicit struct TestTemplateTemplateDefaultType
466 
467 
468 // PR15220 dump instantiation only once
469 namespace testCanonicalTemplate {
470   class A {};
471 
472   template<typename T> void TestFunctionTemplate(T);
473   template<typename T> void TestFunctionTemplate(T);
bar(A a)474   void bar(A a) { TestFunctionTemplate(a); }
475   // CHECK:      FunctionTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-3]]:3, col:51> col:29 TestFunctionTemplate
476   // CHECK-NEXT:   |-TemplateTypeParmDecl 0x{{.+}} <col:12, col:21> col:21 referenced typename depth 0 index 0 T
477   // CHECK-NEXT:   |-FunctionDecl 0x{{.*}} <col:24, col:51> col:29 TestFunctionTemplate 'void (T)'
478   // CHECK-NEXT:   | `-ParmVarDecl 0x{{.*}} <col:50> col:51 'T'
479   // CHECK-NEXT:   `-FunctionDecl 0x{{.*}} <line:[[@LINE-6]]:24, col:51> col:29 used TestFunctionTemplate 'void (testCanonicalTemplate::A)'
480   // CHECK-NEXT:     |-TemplateArgument type 'testCanonicalTemplate::A'
481   // CHECK-NEXT:     | `-RecordType 0x{{.+}} 'testCanonicalTemplate::A'
482   // CHECK-NEXT:     |   `-CXXRecord 0x{{.+}} 'A'
483   // CHECK-NEXT:     `-ParmVarDecl 0x{{.*}} <col:50> col:51 'testCanonicalTemplate::A':'testCanonicalTemplate::A'
484 
485   // CHECK:      FunctionTemplateDecl 0x{{.+}} prev 0x{{.+}} <{{.+}}:[[@LINE-12]]:3, col:51> col:29 TestFunctionTemplate
486   // CHECK-NEXT:   |-TemplateTypeParmDecl 0x{{.+}} <col:12, col:21> col:21 referenced typename depth 0 index 0 T
487   // CHECK-NEXT:   |-FunctionDecl{{.*}} 0x{{.+}} prev 0x{{.+}} <col:24, col:51> col:29 TestFunctionTemplate 'void (T)'
488   // CHECK-NEXT:   | `-ParmVarDecl 0x{{.+}} <col:50> col:51 'T'
489   // CHECK-NEXT:   `-Function 0x{{.+}} 'TestFunctionTemplate' 'void (testCanonicalTemplate::A)'
490   // CHECK-NOT:      TemplateArgument
491 
492   template<typename T1> class TestClassTemplate {
493     template<typename T2> friend class TestClassTemplate;
494   };
495   TestClassTemplate<A> a;
496   // CHECK:      ClassTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-4]]:3, line:[[@LINE-2]]:3> line:[[@LINE-4]]:31 TestClassTemplate
497   // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <col:12, col:21> col:21 typename depth 0 index 0 T1
498   // CHECK-NEXT: |-CXXRecordDecl 0x{{.+}} <col:25, line:[[@LINE-4]]:3> line:[[@LINE-6]]:31 class TestClassTemplate definition
499   // CHECK-NEXT: | |-DefinitionData empty aggregate standard_layout trivially_copyable pod trivial literal has_constexpr_non_copy_move_ctor can_const_default_init
500   // CHECK-NEXT: | | |-DefaultConstructor exists trivial constexpr needs_implicit defaulted_is_constexpr
501   // CHECK-NEXT: | | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param
502   // CHECK-NEXT: | | |-MoveConstructor exists simple trivial needs_implicit
503   // CHECK-NEXT: | | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param
504   // CHECK-NEXT: | | |-MoveAssignment exists simple trivial needs_implicit
505   // CHECK-NEXT: | | `-Destructor simple irrelevant trivial needs_implicit
506   // CHECK-NEXT: | |-CXXRecordDecl 0x{{.+}} <col:25, col:31> col:31 implicit class TestClassTemplate
507   // CHECK-NEXT: | `-FriendDecl 0x{{.+}} <line:[[@LINE-14]]:5, col:40> col:40
508   // CHECK-NEXT: |   `-ClassTemplateDecl 0x{{.+}} parent 0x{{.+}} <col:5, col:40> col:40 TestClassTemplate
509   // CHECK-NEXT: |     |-TemplateTypeParmDecl 0x{{.+}} <col:14, col:23> col:23 typename depth 1 index 0 T2
510   // CHECK-NEXT: |     `-CXXRecordDecl 0x{{.+}} parent 0x{{.+}} <col:34, col:40> col:40 class TestClassTemplate
511   // CHECK-NEXT: `-ClassTemplateSpecializationDecl 0x{{.+}} <line:[[@LINE-19]]:3, line:[[@LINE-17]]:3> line:[[@LINE-19]]:31 class TestClassTemplate definition
512   // 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
513   // CHECK-NEXT:   | |-DefaultConstructor exists trivial constexpr defaulted_is_constexpr
514   // CHECK-NEXT:   | |-CopyConstructor simple trivial has_const_param implicit_has_const_param
515   // CHECK-NEXT:   | |-MoveConstructor exists simple trivial
516   // CHECK-NEXT:   | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param
517   // CHECK-NEXT:   | |-MoveAssignment exists simple trivial needs_implicit
518   // CHECK-NEXT:   | `-Destructor simple irrelevant trivial needs_implicit
519   // CHECK-NEXT:   |-TemplateArgument type 'testCanonicalTemplate::A'
520   // CHECK-NEXT:   | `-RecordType 0x{{.+}} 'testCanonicalTemplate::A'
521   // CHECK-NEXT:   |   `-CXXRecord 0x{{.+}} 'A'
522   // CHECK-NEXT:   |-CXXRecordDecl 0x{{.+}} prev 0x{{.+}} <col:25, col:31> col:31 implicit class TestClassTemplate
523   // CHECK-NEXT:   |-FriendDecl 0x{{.+}} <line:[[@LINE-30]]:5, col:40> col:40
524   // CHECK-NEXT:   | `-ClassTemplateDecl 0x{{.+}} parent 0x{{.+}} prev 0x{{.+}} <col:5, col:40> col:40 TestClassTemplate
525   // CHECK-NEXT:   |   |-TemplateTypeParmDecl 0x{{.+}} <col:14, col:23> col:23 typename depth 0 index 0 T2
526   // CHECK-NEXT:   |   |-CXXRecordDecl 0x{{.+}} parent 0x{{.+}} prev 0x{{.+}} <col:34, col:40> col:40 class TestClassTemplate
527   // CHECK-NEXT:   |   `-ClassTemplateSpecialization 0x{{.+}} 'TestClassTemplate'
528   // CHECK-NEXT:   |-CXXConstructorDecl 0x{{.+}} <line:[[@LINE-36]]:31> col:31 implicit used constexpr TestClassTemplate 'void () noexcept' inline default trivial
529   // CHECK-NEXT:   | `-CompoundStmt 0x{{.+}} <col:31>
530   // CHECK-NEXT:   |-CXXConstructorDecl 0x{{.+}} <col:31> col:31 implicit constexpr TestClassTemplate 'void (const testCanonicalTemplate::TestClassTemplate<testCanonicalTemplate::A> &)' inline default trivial noexcept-unevaluated 0x{{.+}}
531   // CHECK-NEXT:   | `-ParmVarDecl 0x{{.+}} <col:31> col:31 'const testCanonicalTemplate::TestClassTemplate<testCanonicalTemplate::A> &'
532   // CHECK-NEXT:   `-CXXConstructorDecl 0x{{.+}} <col:31> col:31 implicit constexpr TestClassTemplate 'void (testCanonicalTemplate::TestClassTemplate<testCanonicalTemplate::A> &&)' inline default trivial noexcept-unevaluated 0x{{.+}}
533   // CHECK-NEXT:     `-ParmVarDecl 0x{{.+}} <col:31> col:31 'testCanonicalTemplate::TestClassTemplate<testCanonicalTemplate::A> &&'
534 
535 
536   template<typename T1> class TestClassTemplate2;
537   template<typename T1> class TestClassTemplate2;
538   template<typename T1> class TestClassTemplate2 {
539   };
540   TestClassTemplate2<A> a2;
541   // CHECK:      ClassTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-5]]:3, col:31> col:31 TestClassTemplate2
542   // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <col:12, col:21> col:21 typename depth 0 index 0 T1
543   // CHECK-NEXT: |-CXXRecordDecl 0x{{.+}} <col:25, col:31> col:31 class TestClassTemplate2
544   // CHECK-NEXT: `-ClassTemplateSpecializationDecl 0x{{.+}} <line:[[@LINE-6]]:3, line:[[@LINE-5]]:3> line:[[@LINE-6]]:31 class TestClassTemplate2 definition
545   // 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
546   // CHECK-NEXT:   | |-DefaultConstructor exists trivial constexpr defaulted_is_constexpr
547   // CHECK-NEXT:   | |-CopyConstructor simple trivial has_const_param implicit_has_const_param
548   // CHECK-NEXT:   | |-MoveConstructor exists simple trivial
549   // CHECK-NEXT:   | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param
550   // CHECK-NEXT:   | |-MoveAssignment exists simple trivial needs_implicit
551   // CHECK-NEXT:   | `-Destructor simple irrelevant trivial needs_implicit
552   // CHECK-NEXT:   |-TemplateArgument type 'testCanonicalTemplate::A'
553   // CHECK-NEXT:   | `-RecordType 0x{{.+}} 'testCanonicalTemplate::A'
554   // CHECK-NEXT:   |   `-CXXRecord 0x{{.+}} 'A'
555   // CHECK-NEXT:   |-CXXRecordDecl 0x{{.+}} prev 0x{{.+}} <col:25, col:31> col:31 implicit class TestClassTemplate2
556   // CHECK-NEXT:   |-CXXConstructorDecl 0x{{.+}} <col:31> col:31 implicit used constexpr TestClassTemplate2 'void () noexcept' inline default trivial
557   // CHECK-NEXT:   | `-CompoundStmt 0x{{.+}} <col:31>
558   // CHECK-NEXT:   |-CXXConstructorDecl 0x{{.+}} <col:31> col:31 implicit constexpr TestClassTemplate2 'void (const testCanonicalTemplate::TestClassTemplate2<testCanonicalTemplate::A> &)' inline default trivial noexcept-unevaluated 0x{{.+}}
559   // CHECK-NEXT:   | `-ParmVarDecl 0x{{.+}} <col:31> col:31 'const testCanonicalTemplate::TestClassTemplate2<testCanonicalTemplate::A> &'
560   // CHECK-NEXT:   `-CXXConstructorDecl 0x{{.+}} <col:31> col:31 implicit constexpr TestClassTemplate2 'void (testCanonicalTemplate::TestClassTemplate2<testCanonicalTemplate::A> &&)' inline default trivial noexcept-unevaluated 0x{{.+}}
561   // CHECK-NEXT:     `-ParmVarDecl 0x{{.+}} <col:31> col:31 'testCanonicalTemplate::TestClassTemplate2<testCanonicalTemplate::A> &&'
562 
563   // CHECK:      ClassTemplateDecl 0x{{.+}} prev 0x{{.+}} <{{.+}}:[[@LINE-26]]:3, col:31> col:31 TestClassTemplate2
564   // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <col:12, col:21> col:21 typename depth 0 index 0 T1
565   // CHECK-NEXT: |-CXXRecordDecl 0x{{.+}} prev 0x{{.+}} <col:25, col:31> col:31 class TestClassTemplate2
566   // CHECK-NEXT: `-ClassTemplateSpecialization 0x{{.+}} 'TestClassTemplate2'
567 
568   // CHECK:      ClassTemplateDecl 0x{{.+}} prev 0x{{.+}} <{{.+}}:[[@LINE-30]]:3, line:[[@LINE-29]]:3> line:[[@LINE-30]]:31 TestClassTemplate2
569   // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <col:12, col:21> col:21 typename depth 0 index 0 T1
570   // CHECK-NEXT: |-CXXRecordDecl 0x{{.+}} prev 0x{{.+}} <col:25, line:[[@LINE-31]]:3> line:[[@LINE-32]]:31 class TestClassTemplate2 definition
571   // CHECK-NEXT: | |-DefinitionData empty aggregate standard_layout trivially_copyable pod trivial literal has_constexpr_non_copy_move_ctor can_const_default_init
572   // CHECK-NEXT: | | |-DefaultConstructor exists trivial constexpr needs_implicit defaulted_is_constexpr
573   // CHECK-NEXT: | | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param
574   // CHECK-NEXT: | | |-MoveConstructor exists simple trivial needs_implicit
575   // CHECK-NEXT: | | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param
576   // CHECK-NEXT: | | |-MoveAssignment exists simple trivial needs_implicit
577   // CHECK-NEXT: | | `-Destructor simple irrelevant trivial needs_implicit
578   // CHECK-NEXT: | `-CXXRecordDecl 0x{{.+}} <col:25, col:31> col:31 implicit class TestClassTemplate2
579   // CHECK-NEXT: `-ClassTemplateSpecialization 0x{{.+}} 'TestClassTemplate2'
580 
581   struct S {
582       template<typename T> static const T TestVarTemplate; // declaration of a static data member template
583   };
584   template<typename T>
585   const T S::TestVarTemplate = { }; // definition of a static data member template
586 
f()587   void f()
588   {
589     int i = S::TestVarTemplate<int>;
590     int j = S::TestVarTemplate<int>;
591   }
592 
593   // CHECK:      VarTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-11]]:7, col:43> col:43 TestVarTemplate
594   // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <col:16, col:25> col:25 referenced typename depth 0 index 0 T
595   // CHECK-NEXT: |-VarDecl 0x{{.+}} <col:28, col:43> col:43 TestVarTemplate 'const T' static
596   // CHECK-NEXT: |-VarTemplateSpecializationDecl 0x{{.+}} parent 0x{{.+}} prev 0x{{.+}} <line:[[@LINE-11]]:3, col:34> col:14 referenced TestVarTemplate 'const int':'const int' cinit
597   // CHECK-NEXT: | |-TemplateArgument type 'int'
598   // CHECK-NEXT: | | `-BuiltinType 0x{{.+}} 'int'
599   // CHECK-NEXT: | `-InitListExpr 0x{{.+}} <col:32, col:34> 'int':'int'
600   // CHECK-NEXT: `-VarTemplateSpecializationDecl 0x{{.+}} <line:[[@LINE-18]]:28, col:43> col:43 referenced TestVarTemplate 'const int':'const int' static
601   // CHECK-NEXT:   `-TemplateArgument type 'int'
602 
603   // CHECK:     VarTemplateSpecializationDecl 0x{{.+}} <{{.+}}:[[@LINE-21]]:28, col:43> col:43 referenced TestVarTemplate 'const int':'const int' static
604   // CHECK-NEXT:`-TemplateArgument type 'int'
605   // CHECK-NEXT:  `-BuiltinType 0x{{.+}} 'int'
606 
607   // CHECK:      VarTemplateDecl 0x{{.+}} parent 0x{{.+}} prev 0x{{.+}} <{{.+}}:[[@LINE-23]]:3, line:[[@LINE-22]]:34> col:14 TestVarTemplate
608   // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <line:[[@LINE-24]]:12, col:21> col:21 referenced typename depth 0 index 0 T
609   // CHECK-NEXT: |-VarDecl 0x{{.+}} parent 0x{{.+}} prev 0x{{.+}} <line:[[@LINE-24]]:3, col:34> col:14 TestVarTemplate 'const T' cinit
610   // CHECK-NEXT: | `-InitListExpr 0x{{.+}} <col:32, col:34> 'void'
611   // CHECK-NEXT: |-VarTemplateSpecialization 0x{{.+}} 'TestVarTemplate' 'const int':'const int'
612   // CHECK-NEXT: `-VarTemplateSpecialization 0x{{.+}} 'TestVarTemplate' 'const int':'const int'
613 
614   // CHECK:      VarTemplateSpecializationDecl 0x{{.+}} parent 0x{{.+}} prev 0x{{.+}} <{{.+}}:[[@LINE-29]]:3, col:34> col:14 referenced TestVarTemplate 'const int':'const int' cinit
615   // CHECK-NEXT: |-TemplateArgument type 'int'
616   // CHECK-NEXT: | `-BuiltinType 0x{{.+}} 'int'
617   // CHECK-NEXT: `-InitListExpr 0x{{.+}} <col:32, col:34> 'int':'int'
618 }
619 
620 template <class T>
621 class TestClassScopeFunctionSpecialization {
foo(U a)622   template<class U> void foo(U a) { }
foo(int a)623   template<> void foo<int>(int a) { }
624 };
625 // CHECK:      ClassScopeFunctionSpecializationDecl
626 // CHECK-NEXT:   CXXMethod{{.*}} foo 'void (int)'
627 // CHECK-NEXT:     ParmVarDecl
628 // CHECK-NEXT:     CompoundStmt
629 // CHECK-NEXT:   TemplateArgument{{.*}} 'int'
630 
631 namespace TestTemplateTypeParmDecl {
632   template<typename ... T, class U = int> void foo();
633 }
634 // CHECK:      NamespaceDecl{{.*}} TestTemplateTypeParmDecl
635 // CHECK-NEXT:   FunctionTemplateDecl
636 // CHECK-NEXT:     TemplateTypeParmDecl{{.*}} typename depth 0 index 0 ... T
637 // CHECK-NEXT:     TemplateTypeParmDecl{{.*}} class depth 0 index 1 U
638 // CHECK-NEXT:       TemplateArgument type 'int'
639 
640 namespace TestNonTypeTemplateParmDecl {
641   template<int I = 1, int ... J> void foo();
642 }
643 // CHECK:      NamespaceDecl{{.*}} TestNonTypeTemplateParmDecl
644 // CHECK-NEXT:   FunctionTemplateDecl
645 // CHECK-NEXT:     NonTypeTemplateParmDecl{{.*}} 'int' depth 0 index 0 I
646 // CHECK-NEXT:       TemplateArgument expr
647 // CHECK-NEXT:         ConstantExpr{{.*}} 'int'
648 // CHECK-NEXT:           value: Int 1
649 // CHECK-NEXT:           IntegerLiteral{{.*}} 'int' 1
650 // CHECK-NEXT:     NonTypeTemplateParmDecl{{.*}} 'int' depth 0 index 1 ... J
651 
652 namespace TestTemplateTemplateParmDecl {
653   template<typename T> class A;
654   template <template <typename> class T = A, template <typename> class ... U> void foo();
655 }
656 // CHECK:      NamespaceDecl{{.*}} TestTemplateTemplateParmDecl
657 // CHECK:        FunctionTemplateDecl
658 // CHECK-NEXT:     TemplateTemplateParmDecl{{.*}} T
659 // CHECK-NEXT:       TemplateTypeParmDecl{{.*}} typename
660 // CHECK-NEXT:       TemplateArgument{{.*}} template A
661 // CHECK-NEXT:     TemplateTemplateParmDecl{{.*}} ... U
662 // CHECK-NEXT:       TemplateTypeParmDecl{{.*}} typename
663 
664 namespace TestTemplateArgument {
665   template<typename> class A { };
666   template<template<typename> class ...> class B { };
667   int foo();
668 
669   template<typename> class testType { };
670   template class testType<int>;
671   // CHECK:      ClassTemplateSpecializationDecl{{.*}} class testType
672   // CHECK:        TemplateArgument{{.*}} type 'int'
673 
674   template<int fp(void)> class testDecl { };
675   template class testDecl<foo>;
676   // CHECK:      ClassTemplateSpecializationDecl{{.*}} class testDecl
677   // CHECK:        TemplateArgument{{.*}} decl
678   // CHECK-NEXT:     Function{{.*}}foo
679 
680   template class testDecl<nullptr>;
681   // CHECK:      ClassTemplateSpecializationDecl{{.*}} class testDecl
682   // CHECK:        TemplateArgument{{.*}} nullptr
683 
684   template<int> class testIntegral { };
685   template class testIntegral<1>;
686   // CHECK:      ClassTemplateSpecializationDecl{{.*}} class testIntegral
687   // CHECK:        TemplateArgument{{.*}} integral 1
688 
689   template<template<typename> class> class testTemplate { };
690   template class testTemplate<A>;
691   // CHECK:      ClassTemplateSpecializationDecl{{.*}} class testTemplate
692   // CHECK:        TemplateArgument{{.*}} A
693 
694   template<template<typename> class ...T> class C {
695     B<T...> testTemplateExpansion;
696   };
697   // FIXME: Need TemplateSpecializationType dumping to test TemplateExpansion.
698 
699   template<int, int = 0> class testExpr;
700   template<int I> class testExpr<I> { };
701   // CHECK:      ClassTemplatePartialSpecializationDecl{{.*}} class testExpr
702   // CHECK:        TemplateArgument{{.*}} expr
703   // CHECK-NEXT:     DeclRefExpr{{.*}}I
704 
705   template<int, int ...> class testPack { };
706   template class testPack<0, 1, 2>;
707   // CHECK:      ClassTemplateSpecializationDecl{{.*}} class testPack
708   // CHECK:        TemplateArgument{{.*}} integral 0
709   // CHECK-NEXT:   TemplateArgument{{.*}} pack
710   // CHECK-NEXT:     TemplateArgument{{.*}} integral 1
711   // CHECK-NEXT:     TemplateArgument{{.*}} integral 2
712 }
713 
714 namespace testUsingDecl {
715   int i;
716 }
717 namespace TestUsingDecl {
718   using testUsingDecl::i;
719 }
720 // CHECK:      NamespaceDecl{{.*}} TestUsingDecl
721 // CHECK-NEXT:   UsingDecl{{.*}} testUsingDecl::i
722 // CHECK-NEXT:   UsingShadowDecl{{.*}} Var{{.*}} 'i' 'int'
723 
724 namespace testUnresolvedUsing {
725   class A { };
726   template<class T> class B {
727   public:
728     A a;
729   };
730   template<class T> class TestUnresolvedUsing : public B<T> {
731     using typename B<T>::a;
732     using B<T>::a;
733   };
734 }
735 // CHECK: CXXRecordDecl{{.*}} TestUnresolvedUsing
736 // CHECK:   UnresolvedUsingTypenameDecl{{.*}} B<T>::a
737 // CHECK:   UnresolvedUsingValueDecl{{.*}} B<T>::a
738 
739 namespace TestLinkageSpecDecl {
740   extern "C" void test1();
741   extern "C++" void test2();
742 }
743 // CHECK:      NamespaceDecl{{.*}} TestLinkageSpecDecl
744 // CHECK-NEXT:   LinkageSpecDecl{{.*}} C
745 // CHECK-NEXT:     FunctionDecl
746 // CHECK-NEXT:   LinkageSpecDecl{{.*}} C++
747 // CHECK-NEXT:     FunctionDecl
748 
749 class TestAccessSpecDecl {
750 public:
751 private:
752 protected:
753 };
754 // CHECK:      CXXRecordDecl{{.*}} class TestAccessSpecDecl
755 // CHECK:         CXXRecordDecl{{.*}} class TestAccessSpecDecl
756 // CHECK-NEXT:    AccessSpecDecl{{.*}} public
757 // CHECK-NEXT:    AccessSpecDecl{{.*}} private
758 // CHECK-NEXT:    AccessSpecDecl{{.*}} protected
759 
760 template<typename T> class TestFriendDecl {
761   friend int foo();
762   friend class A;
763   friend T;
764 };
765 // CHECK:      CXXRecord{{.*}} TestFriendDecl
766 // CHECK:        CXXRecord{{.*}} TestFriendDecl
767 // CHECK-NEXT:   FriendDecl
768 // CHECK-NEXT:     FunctionDecl{{.*}} foo
769 // CHECK-NEXT:   FriendDecl{{.*}} 'class A':'A'
770 // CHECK-NEXT:   FriendDecl{{.*}} 'T'
771 
772 namespace TestFileScopeAsmDecl {
773   asm("ret");
774 }
775 // CHECK:      NamespaceDecl{{.*}} TestFileScopeAsmDecl{{$}}
776 // CHECK:        FileScopeAsmDecl{{.*> .*$}}
777 // CHECK-NEXT:     StringLiteral
778 
779 namespace TestFriendDecl2 {
780   void f();
781   struct S {
782     friend void f();
783   };
784 }
785 // CHECK: NamespaceDecl [[TestFriendDecl2:0x.*]] <{{.*}}> {{.*}} TestFriendDecl2
786 // CHECK: |-FunctionDecl [[TestFriendDecl2_f:0x.*]] <{{.*}}> {{.*}} f 'void ()'
787 // CHECK: `-CXXRecordDecl {{.*}} struct S
788 // CHECK:   |-CXXRecordDecl {{.*}} struct S
789 // CHECK:   `-FriendDecl
790 // CHECK:     `-FunctionDecl {{.*}} parent [[TestFriendDecl2]] prev [[TestFriendDecl2_f]] <{{.*}}> {{.*}} f 'void ()'
791 
792 namespace Comment {
793   extern int Test;
794   /// Something here.
795   extern int Test;
796   extern int Test;
797 }
798 
799 // CHECK: VarDecl {{.*}} Test 'int' extern
800 // CHECK-NOT: FullComment
801 // CHECK: VarDecl {{.*}} Test 'int' extern
802 // CHECK: `-FullComment
803 // CHECK:   `-ParagraphComment
804 // CHECK:       `-TextComment
805 // CHECK: VarDecl {{.*}} Test 'int' extern
806 // CHECK-NOT: FullComment
807