1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
|
// RUN: %clang_cc1 -std=c++11 -triple x86_64-linux-gnu -fms-extensions -ast-dump -ast-dump-filter Test %s | FileCheck -check-prefix CHECK -strict-whitespace %s
class testEnumDecl {
enum class TestEnumDeclScoped;
enum TestEnumDeclFixed : int;
};
// CHECK: EnumDecl{{.*}} class TestEnumDeclScoped 'int'
// CHECK: EnumDecl{{.*}} TestEnumDeclFixed 'int'
class testFieldDecl {
int TestFieldDeclInit = 0;
};
// CHECK: FieldDecl{{.*}} TestFieldDeclInit 'int'
// CHECK-NEXT: IntegerLiteral
namespace testVarDeclNRVO {
class A { };
A foo() {
A TestVarDeclNRVO;
return TestVarDeclNRVO;
}
}
// CHECK: VarDecl{{.*}} TestVarDeclNRVO 'class testVarDeclNRVO::A' nrvo
void testParmVarDeclInit(int TestParmVarDeclInit = 0);
// CHECK: ParmVarDecl{{.*}} TestParmVarDeclInit 'int'
// CHECK-NEXT: IntegerLiteral{{.*}}
namespace TestNamespaceDecl {
int i;
}
// CHECK: NamespaceDecl{{.*}} TestNamespaceDecl
// CHECK-NEXT: VarDecl
namespace TestNamespaceDecl {
int j;
}
// CHECK: NamespaceDecl{{.*}} TestNamespaceDecl
// CHECK-NEXT: original Namespace
// CHECK-NEXT: VarDecl
inline namespace TestNamespaceDeclInline {
}
// CHECK: NamespaceDecl{{.*}} TestNamespaceDeclInline inline
namespace testUsingDirectiveDecl {
namespace A {
}
}
namespace TestUsingDirectiveDecl {
using namespace testUsingDirectiveDecl::A;
}
// CHECK: NamespaceDecl{{.*}} TestUsingDirectiveDecl
// CHECK-NEXT: UsingDirectiveDecl{{.*}} Namespace{{.*}} 'A'
namespace testNamespaceAlias {
namespace A {
}
}
namespace TestNamespaceAlias = testNamespaceAlias::A;
// CHECK: NamespaceAliasDecl{{.*}} TestNamespaceAlias
// CHECK-NEXT: Namespace{{.*}} 'A'
using TestTypeAliasDecl = int;
// CHECK: TypeAliasDecl{{.*}} TestTypeAliasDecl 'int'
namespace testTypeAliasTemplateDecl {
template<typename T> class A;
template<typename T> using TestTypeAliasTemplateDecl = A<T>;
}
// CHECK: TypeAliasTemplateDecl{{.*}} TestTypeAliasTemplateDecl
// CHECK-NEXT: TemplateTypeParmDecl
// CHECK-NEXT: TypeAliasDecl{{.*}} TestTypeAliasTemplateDecl 'A<T>'
namespace testCXXRecordDecl {
class A { };
class B { };
class TestCXXRecordDecl : virtual A, public B {
int i;
};
}
// CHECK: CXXRecordDecl{{.*}} class TestCXXRecordDecl
// CHECK-NEXT: virtual private 'class testCXXRecordDecl::A'
// CHECK-NEXT: public 'class testCXXRecordDecl::B'
// CHECK-NEXT: CXXRecordDecl{{.*}} class TestCXXRecordDecl
// CHECK-NEXT: FieldDecl
template<class...T>
class TestCXXRecordDeclPack : public T... {
};
// CHECK: CXXRecordDecl{{.*}} class TestCXXRecordDeclPack
// CHECK-NEXT: public 'T'...
// CHECK-NEXT: CXXRecordDecl{{.*}} class TestCXXRecordDeclPack
thread_local int TestThreadLocalInt;
// CHECK: TestThreadLocalInt {{.*}} tls_dynamic
__module_private__ class TestCXXRecordDeclPrivate;
// CHECK: CXXRecordDecl{{.*}} class TestCXXRecordDeclPrivate __module_private__
class testCXXMethodDecl {
__module_private__ void TestCXXMethodDeclPrivate();
virtual void TestCXXMethodDeclPure() = 0;
void TestCXXMethodDeclDelete() = delete;
void TestCXXMethodDeclThrow() throw();
void TestCXXMethodDeclThrowType() throw(int);
};
// CHECK: CXXMethodDecl{{.*}} TestCXXMethodDeclPrivate 'void (void)' __module_private__
// CHECK: CXXMethodDecl{{.*}} TestCXXMethodDeclPure 'void (void)' virtual pure
// CHECK: CXXMethodDecl{{.*}} TestCXXMethodDeclDelete 'void (void)' delete
// CHECK: CXXMethodDecl{{.*}} TestCXXMethodDeclThrow 'void (void) throw()'
// CHECK: CXXMethodDecl{{.*}} TestCXXMethodDeclThrowType 'void (void) throw(int)'
namespace testCXXConstructorDecl {
class A { };
class TestCXXConstructorDecl : public A {
int I;
TestCXXConstructorDecl(A &a, int i) : A(a), I(i) { }
};
}
// CHECK: CXXConstructorDecl{{.*}} TestCXXConstructorDecl 'void {{.*}}'
// CHECK-NEXT: ParmVarDecl{{.*}} a
// CHECK-NEXT: ParmVarDecl{{.*}} i
// CHECK-NEXT: CXXCtorInitializer{{.*}}A
// CHECK-NEXT: Expr
// CHECK: CXXCtorInitializer{{.*}}I
// CHECK-NEXT: Expr
// CHECK: CompoundStmt
class TestCXXDestructorDecl {
~TestCXXDestructorDecl() { }
};
// CHECK: CXXDestructorDecl{{.*}} ~TestCXXDestructorDecl 'void (void) noexcept'
// CHECK-NEXT: CompoundStmt
class TestCXXConversionDecl {
operator int() { return 0; }
};
// CHECK: CXXConversionDecl{{.*}} operator int 'int (void)'
// CHECK-NEXT: CompoundStmt
namespace TestStaticAssertDecl {
static_assert(true, "msg");
}
// CHECK: NamespaceDecl{{.*}} TestStaticAssertDecl
// CHECK-NEXT: StaticAssertDecl{{.*>$}}
// CHECK-NEXT: CXXBoolLiteralExpr
// CHECK-NEXT: StringLiteral
namespace testFunctionTemplateDecl {
class A { };
class B { };
class C { };
class D { };
template<typename T> void TestFunctionTemplate(T) { }
// implicit instantiation
void bar(A a) { TestFunctionTemplate(a); }
// explicit specialization
template<> void TestFunctionTemplate(B);
// explicit instantiation declaration
extern template void TestFunctionTemplate(C);
// explicit instantiation definition
template void TestFunctionTemplate(D);
}
// CHECK: FunctionTemplateDecl{{.*}} TestFunctionTemplate
// CHECK-NEXT: TemplateTypeParmDecl
// CHECK-NEXT: FunctionDecl{{.*}} TestFunctionTemplate 'void (T)'
// CHECK-NEXT: ParmVarDecl{{.*}} 'T'
// CHECK-NEXT: CompoundStmt
// CHECK-NEXT: FunctionDecl{{.*}} TestFunctionTemplate {{.*}}A
// CHECK-NEXT: TemplateArgument
// CHECK-NEXT: ParmVarDecl
// CHECK-NEXT: CompoundStmt
// CHECK-NEXT: Function{{.*}} 'TestFunctionTemplate' {{.*}}B
// CHECK-NEXT: FunctionDecl{{.*}} TestFunctionTemplate {{.*}}C
// CHECK-NEXT: TemplateArgument
// CHECK-NEXT: ParmVarDecl
// CHECK-NEXT: FunctionDecl{{.*}} TestFunctionTemplate {{.*}}D
// CHECK-NEXT: TemplateArgument
// CHECK-NEXT: ParmVarDecl
// CHECK-NEXT: CompoundStmt
// CHECK: FunctionDecl{{.*}} TestFunctionTemplate {{.*}}B
// CHECK-NEXT: TemplateArgument
// CHECK-NEXT: ParmVarDecl
namespace testClassTemplateDecl {
class A { };
class B { };
class C { };
class D { };
template<typename T> class TestClassTemplate {
int i;
};
// implicit instantiation
TestClassTemplate<A> a;
// explicit specialization
template<> class TestClassTemplate<B> {
int j;
};
// explicit instantiation declaration
extern template class TestClassTemplate<C>;
// explicit instantiation definition
template class TestClassTemplate<D>;
// partial explicit specialization
template<typename T1, typename T2> class TestClassTemplatePartial {
int i;
};
template<typename T1> class TestClassTemplatePartial<T1, A> {
int j;
};
}
// CHECK: ClassTemplateDecl{{.*}} TestClassTemplate
// CHECK-NEXT: TemplateTypeParmDecl
// CHECK-NEXT: CXXRecordDecl{{.*}} class TestClassTemplate
// CHECK-NEXT: CXXRecordDecl{{.*}} class TestClassTemplate
// CHECK-NEXT: FieldDecl{{.*}} i
// CHECK-NEXT: ClassTemplateSpecializationDecl{{.*}} class TestClassTemplate
// CHECK-NEXT: TemplateArgument{{.*}}A
// CHECK-NEXT: CXXRecordDecl{{.*}} class TestClassTemplate
// CHECK-NEXT: FieldDecl{{.*}} i
// CHECK: ClassTemplateSpecialization{{.*}} 'TestClassTemplate'
// CHECK-NEXT: ClassTemplateSpecialization{{.*}} 'TestClassTemplate'
// CHECK-NEXT: ClassTemplateSpecialization{{.*}} 'TestClassTemplate'
// CHECK: ClassTemplateSpecializationDecl{{.*}} class TestClassTemplate
// CHECK-NEXT: TemplateArgument{{.*}}B
// CHECK-NEXT: CXXRecordDecl{{.*}} class TestClassTemplate
// CHECK-NEXT: FieldDecl{{.*}} j
// CHECK: ClassTemplateSpecializationDecl{{.*}} class TestClassTemplate
// CHECK-NEXT: TemplateArgument{{.*}}C
// CHECK-NEXT: CXXRecordDecl{{.*}} class TestClassTemplate
// CHECK-NEXT: FieldDecl{{.*}} i
// CHECK: ClassTemplateSpecializationDecl{{.*}} class TestClassTemplate
// CHECK-NEXT: TemplateArgument{{.*}}D
// CHECK-NEXT: CXXRecordDecl{{.*}} class TestClassTemplate
// CHECK-NEXT: FieldDecl{{.*}} i
// CHECK: ClassTemplatePartialSpecializationDecl{{.*}} class TestClassTemplatePartial
// CHECK-NEXT: TemplateArgument
// CHECK-NEXT: TemplateArgument{{.*}}A
// CHECK-NEXT: TemplateTypeParmDecl
// CHECK-NEXT: CXXRecordDecl{{.*}} class TestClassTemplatePartial
// CHECK-NEXT: FieldDecl{{.*}} j
// PR15220 dump instantiation only once
namespace testCanonicalTemplate {
class A {};
template<typename T> void TestFunctionTemplate(T);
template<typename T> void TestFunctionTemplate(T);
void bar(A a) { TestFunctionTemplate(a); }
// CHECK: FunctionTemplateDecl{{.*}} TestFunctionTemplate
// CHECK-NEXT: TemplateTypeParmDecl
// CHECK-NEXT: FunctionDecl{{.*}} TestFunctionTemplate 'void (T)'
// CHECK-NEXT: ParmVarDecl{{.*}} 'T'
// CHECK-NEXT: FunctionDecl{{.*}} TestFunctionTemplate {{.*}}A
// CHECK-NEXT: TemplateArgument
// CHECK-NEXT: ParmVarDecl
// CHECK: FunctionTemplateDecl{{.*}} TestFunctionTemplate
// CHECK-NEXT: TemplateTypeParmDecl
// CHECK-NEXT: FunctionDecl{{.*}} TestFunctionTemplate 'void (T)'
// CHECK-NEXT: ParmVarDecl{{.*}} 'T'
// CHECK-NEXT: Function{{.*}} 'TestFunctionTemplate'
// CHECK-NEXT-NOT: TemplateArgument
template<typename T1> class TestClassTemplate {
template<typename T2> friend class TestClassTemplate;
};
TestClassTemplate<A> a;
// CHECK: ClassTemplateDecl{{.*}} TestClassTemplate
// CHECK-NEXT: TemplateTypeParmDecl
// CHECK-NEXT: CXXRecordDecl{{.*}} class TestClassTemplate
// CHECK-NEXT: CXXRecordDecl{{.*}} class TestClassTemplate
// CHECK-NEXT: FriendDecl
// CHECK-NEXT: ClassTemplateDecl{{.*}} TestClassTemplate
// CHECK-NEXT: TemplateTypeParmDecl
// CHECK-NEXT: CXXRecordDecl{{.*}} class TestClassTemplate
// CHECK-NEXT: ClassTemplateSpecialization{{.*}} 'TestClassTemplate'
// CHECK-NEXT: ClassTemplateSpecializationDecl{{.*}} class TestClassTemplate
// CHECK-NEXT: TemplateArgument{{.*}}A
// CHECK-NEXT: CXXRecordDecl{{.*}} class TestClassTemplate
}
template <class T>
class TestClassScopeFunctionSpecialization {
template<class U> void foo(U a) { }
template<> void foo<int>(int a) { }
};
// CHECK: ClassScopeFunctionSpecializationDecl
// CHECK-NEXT: CXXMethod{{.*}} 'foo' 'void (int)'
// CHECK-NEXT: TemplateArgument{{.*}} 'int'
namespace TestTemplateTypeParmDecl {
template<typename ... T, class U = int> void foo();
}
// CHECK: NamespaceDecl{{.*}} TestTemplateTypeParmDecl
// CHECK-NEXT: FunctionTemplateDecl
// CHECK-NEXT: TemplateTypeParmDecl{{.*}} typename ... T
// CHECK-NEXT: TemplateTypeParmDecl{{.*}} class U 'int'
namespace TestNonTypeTemplateParmDecl {
template<int I = 1, int ... J> void foo();
}
// CHECK: NamespaceDecl{{.*}} TestNonTypeTemplateParmDecl
// CHECK-NEXT: FunctionTemplateDecl
// CHECK-NEXT: NonTypeTemplateParmDecl{{.*}} 'int' I
// CHECK-NEXT: IntegerLiteral{{.*}} 'int' 1
// CHECK-NEXT: NonTypeTemplateParmDecl{{.*}} 'int' ... J
namespace TestTemplateTemplateParmDecl {
template<typename T> class A;
template <template <typename> class T = A, template <typename> class ... U> void foo();
}
// CHECK: NamespaceDecl{{.*}} TestTemplateTemplateParmDecl
// CHECK: FunctionTemplateDecl
// CHECK-NEXT: TemplateTemplateParmDecl{{.*}} T
// CHECK-NEXT: TemplateTypeParmDecl{{.*}} typename
// CHECK-NEXT: TemplateArgument{{.*}} template A
// CHECK-NEXT: TemplateTemplateParmDecl{{.*}} ... U
// CHECK-NEXT: TemplateTypeParmDecl{{.*}} typename
namespace TestTemplateArgument {
template<typename> class A { };
template<template<typename> class ...> class B { };
int foo();
template<typename> class testType { };
template class testType<int>;
// CHECK: ClassTemplateSpecializationDecl{{.*}} class testType
// CHECK-NEXT: TemplateArgument{{.*}} type 'int'
template<int fp(void)> class testDecl { };
template class testDecl<foo>;
// CHECK: ClassTemplateSpecializationDecl{{.*}} class testDecl
// CHECK-NEXT: TemplateArgument{{.*}} decl
// CHECK-NEXT: Function{{.*}}foo
template class testDecl<nullptr>;
// CHECK: ClassTemplateSpecializationDecl{{.*}} class testDecl
// CHECK-NEXT: TemplateArgument{{.*}} nullptr
template<int> class testIntegral { };
template class testIntegral<1>;
// CHECK: ClassTemplateSpecializationDecl{{.*}} class testIntegral
// CHECK-NEXT: TemplateArgument{{.*}} integral 1
template<template<typename> class> class testTemplate { };
template class testTemplate<A>;
// CHECK: ClassTemplateSpecializationDecl{{.*}} class testTemplate
// CHECK-NEXT: TemplateArgument{{.*}} A
template<template<typename> class ...T> class C {
B<T...> testTemplateExpansion;
};
// FIXME: Need TemplateSpecializationType dumping to test TemplateExpansion.
template<int, int = 0> class testExpr;
template<int I> class testExpr<I> { };
// CHECK: ClassTemplatePartialSpecializationDecl{{.*}} class testExpr
// CHECK-NEXT: TemplateArgument{{.*}} expr
// CHECK-NEXT: DeclRefExpr{{.*}}I
template<int, int ...> class testPack { };
template class testPack<0, 1, 2>;
// CHECK: ClassTemplateSpecializationDecl{{.*}} class testPack
// CHECK-NEXT: TemplateArgument{{.*}} integral 0
// CHECK-NEXT: TemplateArgument{{.*}} pack
// CHECK-NEXT: TemplateArgument{{.*}} integral 1
// CHECK-NEXT: TemplateArgument{{.*}} integral 2
}
namespace testUsingDecl {
int i;
}
namespace TestUsingDecl {
using testUsingDecl::i;
}
// CHECK: NamespaceDecl{{.*}} TestUsingDecl
// CHECK-NEXT: UsingDecl{{.*}} testUsingDecl::i
// CHECK-NEXT: UsingShadowDecl{{.*}} Var{{.*}} 'i' 'int'
namespace testUnresolvedUsing {
class A { };
template<class T> class B {
public:
A a;
};
template<class T> class TestUnresolvedUsing : public B<T> {
using typename B<T>::a;
using B<T>::a;
};
}
// CHECK: CXXRecordDecl{{.*}} TestUnresolvedUsing
// CHECK: UnresolvedUsingTypenameDecl{{.*}} B<T>::a
// CHECK: UnresolvedUsingValueDecl{{.*}} B<T>::a
namespace TestLinkageSpecDecl {
extern "C" void test1();
extern "C++" void test2();
}
// CHECK: NamespaceDecl{{.*}} TestLinkageSpecDecl
// CHECK-NEXT: LinkageSpecDecl{{.*}} C
// CHECK-NEXT: FunctionDecl
// CHECK-NEXT: LinkageSpecDecl{{.*}} C++
// CHECK-NEXT: FunctionDecl
class TestAccessSpecDecl {
public:
private:
protected:
};
// CHECK: CXXRecordDecl{{.*}} class TestAccessSpecDecl
// CHECK-NEXT: CXXRecordDecl{{.*}} class TestAccessSpecDecl
// CHECK-NEXT: AccessSpecDecl{{.*}} public
// CHECK-NEXT: AccessSpecDecl{{.*}} private
// CHECK-NEXT: AccessSpecDecl{{.*}} protected
template<typename T> class TestFriendDecl {
friend int foo();
friend class A;
friend T;
};
// CHECK: CXXRecord{{.*}} TestFriendDecl
// CHECK-NEXT: CXXRecord{{.*}} TestFriendDecl
// CHECK-NEXT: FriendDecl
// CHECK-NEXT: FunctionDecl{{.*}} foo
// CHECK-NEXT: FriendDecl{{.*}} 'class A':'class A'
// CHECK-NEXT: FriendDecl{{.*}} 'T'
namespace TestFileScopeAsmDecl {
asm("ret");
}
// CHECK: NamespaceDecl{{.*}} TestFileScopeAsmDecl{{$}}
// CHECK: FileScopeAsmDecl{{.*>$}}
// CHECK-NEXT: StringLiteral
namespace TestFriendDecl2 {
void f();
struct S {
friend void f();
};
}
// CHECK: NamespaceDecl [[TestFriendDecl2:0x.*]] <{{.*}}> TestFriendDecl2
// CHECK: |-FunctionDecl [[TestFriendDecl2_f:0x.*]] <{{.*}}> f 'void (void)'
// CHECK: `-CXXRecordDecl {{.*}} struct S
// CHECK: |-CXXRecordDecl {{.*}} struct S
// CHECK: `-FriendDecl
// CHECK: `-FunctionDecl {{.*}} parent [[TestFriendDecl2]] prev [[TestFriendDecl2_f]] <{{.*}}> f 'void (void)'
|