diff --git a/clang/test/AST/ast-dump-template-decls.cpp b/clang/test/AST/ast-dump-template-decls.cpp --- a/clang/test/AST/ast-dump-template-decls.cpp +++ b/clang/test/AST/ast-dump-template-decls.cpp @@ -1,12 +1,12 @@ // Test without serialization: // RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown -ast-dump %s \ -// RUN: | FileCheck -strict-whitespace %s +// RUN: | FileCheck -strict-whitespace %s --check-prefix=DIRECT // // Test with serialization: // RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown -emit-pch -o %t %s // RUN: %clang_cc1 -x c++ -std=c++17 -triple x86_64-unknown-unknown -include-pch %t -ast-dump-all /dev/null \ // RUN: | sed -e "s/ //" -e "s/ imported//" \ -// RUN: | FileCheck --strict-whitespace %s +// RUN: | FileCheck --strict-whitespace %s --check-prefix=SERIALIZED template // CHECK: FunctionTemplateDecl 0x{{[^ ]*}} <{{.*}}:1, line:[[@LINE+2]]:10> col:6 a @@ -178,3 +178,80 @@ // CHECK-NEXT: `-RecordType 0x{{[^ ]*}} 'subst_default_argument::A' // CHECK-NEXT: `-ClassTemplateSpecialization 0x{{[^ ]*}} 'A' } // namespace subst_default_argument + +namespace D146733 { +template +T unTempl = 1; +// CHECK:VarTemplateDecl 0x{{[^ ]*}} col:3 unTempl +// CHECK-NEXT: |-TemplateTypeParmDecl 0x{{[^ ]*}} col:16 referenced class depth 0 index 0 T +// CHECK-NEXT: |-VarDecl 0x{{[^ ]*}} col:3 unTempl 'T' cinit +// CHECK-NEXT: | `-IntegerLiteral 0x{{[^ ]*}} 'int' 1 + +template<> +int unTempl; +// FIXME (#61680) - serializing and loading AST should not affect reported source range +// DIRECT: VarTemplateSpecializationDecl 0x{{[^ ]*}} col:5 unTempl 'int' +// SERIALIZED: VarTemplateSpecializationDecl 0x{{[^ ]*}} col:5 unTempl 'int' +// CHECK-NEXT: `-TemplateArgument type 'int' +// CHECK-NEXT: `-BuiltinType 0x{{[^ ]*}} 'int' + +template<> +float unTempl = 1; +// FIXME (#61680) - serializing and loading AST should not affect reported source range +// DIRECT: VarTemplateSpecializationDecl 0x{{[^ ]*}} col:7 unTempl 'float' cinit +// SERIALIZED: VarTemplateSpecializationDecl 0x{{[^ ]*}} col:7 unTempl 'float' cinit +// CHECK-NEXT: |-TemplateArgument type 'float' +// CHECK-NEXT: | `-BuiltinType 0x{{[^ ]*}} 'float' +// CHECK-NEXT: `-ImplicitCastExpr 0x{{[^ ]*}} 'float' +// CHECK-NEXT: `-IntegerLiteral 0x{{[^ ]*}} 'int' 1 + +template +T binTempl = 1; +// CHECK: VarTemplateDecl 0x{{[^ ]*}} col:3 binTempl +// CHECK-NEXT: |-TemplateTypeParmDecl 0x{{[^ ]*}} col:16 referenced class depth 0 index 0 T +// CHECK-NEXT: |-TemplateTypeParmDecl 0x{{[^ ]*}} col:25 class depth 0 index 1 U +// CHECK-NEXT: |-VarDecl 0x{{[^ ]*}} col:3 binTempl 'T' cinit +// CHECK-NEXT: | `-IntegerLiteral 0x{{[^ ]*}} 'int' 1 + +template +int binTempl; +// CHECK: VarTemplatePartialSpecializationDecl 0x{{[^ ]*}} col:5 binTempl 'int' +// CHECK-NEXT: |-TemplateTypeParmDecl 0x{{[^ ]*}} col:16 referenced class depth 0 index 0 U +// CHECK-NEXT: |-TemplateArgument type 'int' +// CHECK-NEXT: | `-BuiltinType 0x{{[^ ]*}} 'int' +// CHECK-NEXT: `-TemplateArgument type 'type-parameter-0-0' +// CHECK-NEXT: `-TemplateTypeParmType 0x{{[^ ]*}} 'type-parameter-0-0' dependent depth 0 index 0 + +template +float binTempl = 1; +// CHECK: VarTemplatePartialSpecializationDecl 0x{{[^ ]*}} col:7 binTempl 'float' cinit +// CHECK-NEXT: |-TemplateTypeParmDecl 0x{{[^ ]*}} col:16 referenced class depth 0 index 0 U +// CHECK-NEXT: |-TemplateArgument type 'float' +// CHECK-NEXT: | `-BuiltinType 0x{{[^ ]*}} 'float' +// CHECK-NEXT: |-TemplateArgument type 'type-parameter-0-0' +// CHECK-NEXT: | `-TemplateTypeParmType 0x{{[^ ]*}} 'type-parameter-0-0' dependent depth 0 index 0 +// CHECK-NEXT: `-ImplicitCastExpr 0x{{[^ ]*}} 'float' +// CHECK-NEXT: `-IntegerLiteral 0x{{[^ ]*}} 'int' 1 + +template<> +int binTempl; +// FIXME (#61680) - serializing and loading AST should not affect reported source range +// DIRECT: VarTemplateSpecializationDecl 0x{{[^ ]*}} col:5 binTempl 'int' +// SERIALIZED: VarTemplateSpecializationDecl 0x{{[^ ]*}} col:5 binTempl 'int' +// CHECK-NEXT: |-TemplateArgument type 'int' +// CHECK-NEXT: | `-BuiltinType 0x{{[^ ]*}} 'int' +// CHECK-NEXT: `-TemplateArgument type 'int' +// CHECK-NEXT: `-BuiltinType 0x{{[^ ]*}} 'int' + +template<> +float binTempl = 1; +// FIXME (#61680) - serializing and loading AST should not affect reported source range +// DIRECT: VarTemplateSpecializationDecl 0x{{[^ ]*}} col:7 binTempl 'float' cinit +// SERIALIZED: VarTemplateSpecializationDecl 0x{{[^ ]*}} col:7 binTempl 'float' cinit +// CHECK-NEXT: |-TemplateArgument type 'float' +// CHECK-NEXT: | `-BuiltinType 0x{{[^ ]*}} 'float' +// CHECK-NEXT: |-TemplateArgument type 'float' +// CHECK-NEXT: | `-BuiltinType 0x{{[^ ]*}} 'float' +// CHECK-NEXT: `-ImplicitCastExpr 0x{{[^ ]*}} 'float' +// CHECK-NEXT: `-IntegerLiteral 0x{{[^ ]*}} 'int' 1 +}