diff --git a/clang/test/AST/ast-dump-template-decls.cpp b/clang/test/AST/ast-dump-template-decls.cpp new file mode 100644 index 000000000000..a1f355b4da0d --- /dev/null +++ b/clang/test/AST/ast-dump-template-decls.cpp @@ -0,0 +1,102 @@ +// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown -ast-dump %s | FileCheck -strict-whitespace %s + +template +// CHECK: FunctionTemplateDecl 0x{{[^ ]*}} <{{.*}}:1, line:[[@LINE+2]]:10> col:6 a +// CHECK-NEXT: TemplateTypeParmDecl 0x{{[^ ]*}} col:20 referenced typename depth 0 index 0 Ty +void a(Ty); + +template +// CHECK: FunctionTemplateDecl 0x{{[^ ]*}} col:6 b +// CHECK-NEXT: TemplateTypeParmDecl 0x{{[^ ]*}} col:23 referenced typename depth 0 index 0 ... Ty +void b(Ty...); + +template +// CHECK: FunctionTemplateDecl 0x{{[^ ]*}} col:6 c +// CHECK-NEXT: TemplateTypeParmDecl 0x{{[^ ]*}} col:20 referenced typename depth 0 index 0 Ty +// CHECK-NEXT: TemplateTypeParmDecl 0x{{[^ ]*}} col:33 referenced typename depth 0 index 1 Uy +void c(Ty, Uy); + +template <> +void c(float, int); +// CHECK: FunctionDecl 0x{{[^ ]*}} prev 0x{{[^ ]*}} col:6 c 'void (float, int)' +// CHECK: TemplateArgument type 'float' +// CHECK: TemplateArgument type 'int' + +template typename Uy> +// CHECK: FunctionTemplateDecl 0x{{[^ ]*}} col:6 d +// CHECK-NEXT: TemplateTypeParmDecl 0x{{[^ ]*}} col:20 referenced typename depth 0 index 0 Ty +// CHECK-NEXT: TemplateTemplateParmDecl 0x{{[^ ]*}} col:52 depth 0 index 1 Uy +// CHECK-NEXT: TemplateTypeParmDecl 0x{{[^ ]*}} col:33 typename depth 1 index 0 +void d(Ty, Uy); + +template +// CHECK: FunctionTemplateDecl 0x{{[^ ]*}} col:6 e +// CHECK-NEXT: TemplateTypeParmDecl 0x{{[^ ]*}} col:17 referenced class depth 0 index 0 Ty +void e(Ty); + +template +// CHECK: FunctionTemplateDecl 0x{{[^ ]*}} col:6 f +// CHECK-NEXT: NonTypeTemplateParmDecl 0x{{[^ ]*}} col:15 referenced 'int' depth 0 index 0 N +void f(int i = N); + +template +// CHECK: FunctionTemplateDecl 0x{{[^ ]*}} col:6 g +// CHECK-NEXT: TemplateTypeParmDecl 0x{{[^ ]*}} col:20 referenced typename depth 0 index 0 Ty +// CHECK-NEXT: TemplateArgument type 'int' +void g(Ty); + +template +// CHECK: FunctionTemplateDecl 0x{{[^ ]*}} col:6 h +// CHECK-NEXT: TemplateTypeParmDecl 0x{{[^ ]*}} col:11 typename depth 0 index 0 +// CHECK-NEXT: TemplateArgument type 'void' +void h(); + +template +// CHECK: ClassTemplateDecl 0x{{[^ ]*}} col:8 R +// CHECK-NEXT: TemplateTypeParmDecl 0x{{[^ ]*}} col:20 typename depth 0 index 0 Ty +// CHECK: ClassTemplateSpecialization 0x{{[^ ]*}} 'R' +struct R {}; + +template <> +// CHECK: ClassTemplateSpecializationDecl 0x{{[^ ]*}} col:8 struct R definition +// CHECK: TemplateArgument type 'int' +struct R {}; + +template +// CHECK: ClassTemplateDecl 0x{{[^ ]*}} col:8 S +// CHECK-NEXT: TemplateTypeParmDecl 0x{{[^ ]*}} col:20 typename depth 0 index 0 Ty +// CHECK-NEXT: TemplateTypeParmDecl 0x{{[^ ]*}} col:30 class depth 0 index 1 Uy +struct S {}; + +template +// CHECK: ClassTemplatePartialSpecializationDecl 0x{{[^ ]*}} col:8 struct S definition +// CHECK: TemplateArgument type 'type-parameter-0-0' +// CHECK-NEXT: TemplateArgument type 'int' +// CHECK-NEXT: TemplateTypeParmDecl 0x{{[^ ]*}} col:20 referenced typename depth 0 index 0 Ty +struct S {}; + +template +// CHECK: ClassTemplateDecl 0x{{[^ ]*}} col:8 T +// CHECK-NEXT: NonTypeTemplateParmDecl 0x{{[^ ]*}} col:15 'auto' depth 0 index 0 +struct T {}; + +template +// CHECK: ClassTemplateDecl 0x{{[^ ]*}} col:8 U +// CHECK-NEXT: NonTypeTemplateParmDecl 0x{{[^ ]*}} col:25 'decltype(auto)' depth 0 index 0 +struct U {}; + +template +// CHECK: ClassTemplateDecl 0x{{[^ ]*}} line:[[@LINE+2]]:8 V +// CHECK-NEXT: TemplateTypeParmDecl 0x{{[^ ]*}} col:20 typename depth 0 index 0 Ty +struct V { + template + // CHECK: FunctionTemplateDecl 0x{{[^ ]*}} col:8 f + // CHECK-NEXT: TemplateTypeParmDecl 0x{{[^ ]*}} col:22 typename depth 1 index 0 Uy + void f(); +}; + +template +template +// CHECK: FunctionTemplateDecl 0x{{[^ ]*}} parent 0x{{[^ ]*}} prev 0x{{[^ ]*}} col:13 f +// CHECK-NEXT: TemplateTypeParmDecl 0x{{[^ ]*}} col:20 typename depth 1 index 0 Uy +void V::f() {}