From: Richard Smith Date: Tue, 23 Jun 2020 07:01:38 +0000 (-0700) Subject: AST dump: recurse into type template arguments when dumping. X-Git-Tag: llvmorg-12-init~2270 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5eca1d5e0d22a2a578370fdc780cd4003e28ad61;p=platform%2Fupstream%2Fllvm.git AST dump: recurse into type template arguments when dumping. Also, do not dump the desugared type for a TemplateSpecializationType twice. --- diff --git a/clang/include/clang/AST/ASTNodeTraverser.h b/clang/include/clang/AST/ASTNodeTraverser.h index c146c24..7462120e 100644 --- a/clang/include/clang/AST/ASTNodeTraverser.h +++ b/clang/include/clang/AST/ASTNodeTraverser.h @@ -352,8 +352,6 @@ public: void VisitTemplateSpecializationType(const TemplateSpecializationType *T) { for (const auto &Arg : *T) Visit(Arg); - if (T->isTypeAlias()) - Visit(T->getAliasedType()); } void VisitObjCObjectPointerType(const ObjCObjectPointerType *T) { Visit(T->getPointeeType()); @@ -690,6 +688,11 @@ public: void VisitExpressionTemplateArgument(const TemplateArgument &TA) { Visit(TA.getAsExpr()); } + + void VisitTypeTemplateArgument(const TemplateArgument &TA) { + Visit(TA.getAsType()); + } + void VisitPackTemplateArgument(const TemplateArgument &TA) { for (const auto &TArg : TA.pack_elements()) Visit(TArg); diff --git a/clang/test/AST/ast-dump-decl.cpp b/clang/test/AST/ast-dump-decl.cpp index 3809683..b9b7cba 100644 --- a/clang/test/AST/ast-dump-decl.cpp +++ b/clang/test/AST/ast-dump-decl.cpp @@ -224,19 +224,27 @@ namespace testFunctionTemplateDecl { // CHECK-NEXT: | `-CompoundStmt 0x{{.+}} // CHECK-NEXT: |-FunctionDecl 0x{{.+}} col:29 used TestFunctionTemplate 'void (testFunctionTemplateDecl::A)' // CHECK-NEXT: | |-TemplateArgument type 'testFunctionTemplateDecl::A' + // CHECK-NEXT: | | `-RecordType 0{{.+}} 'testFunctionTemplateDecl::A' + // CHECK-NEXT: | | `-CXXRecord 0x{{.+}} 'A' // CHECK-NEXT: | |-ParmVarDecl 0x{{.+}} col:51 'testFunctionTemplateDecl::A':'testFunctionTemplateDecl::A' // CHECK-NEXT: | `-CompoundStmt 0x{{.+}} // CHECK-NEXT: |-Function 0x{{.+}} 'TestFunctionTemplate' 'void (testFunctionTemplateDecl::B)' // CHECK-NEXT: |-FunctionDecl 0x{{.+}} col:29 TestFunctionTemplate 'void (testFunctionTemplateDecl::C)' // CHECK-NEXT: | |-TemplateArgument type 'testFunctionTemplateDecl::C' + // CHECK-NEXT: | | `-RecordType 0{{.+}} 'testFunctionTemplateDecl::C' + // CHECK-NEXT: | | `-CXXRecord 0x{{.+}} 'C' // CHECK-NEXT: | `-ParmVarDecl 0x{{.+}} col:51 'testFunctionTemplateDecl::C':'testFunctionTemplateDecl::C' // CHECK-NEXT: `-FunctionDecl 0x{{.+}} col:29 TestFunctionTemplate 'void (testFunctionTemplateDecl::D)' // CHECK-NEXT: |-TemplateArgument type 'testFunctionTemplateDecl::D' + // CHECK-NEXT: | `-RecordType 0{{.+}} 'testFunctionTemplateDecl::D' + // CHECK-NEXT: | `-CXXRecord 0x{{.+}} 'D' // CHECK-NEXT: |-ParmVarDecl 0x{{.+}} col:51 'testFunctionTemplateDecl::D':'testFunctionTemplateDecl::D' // CHECK-NEXT: `-CompoundStmt 0x{{.+}} - // CHECK: FunctionDecl 0x{{.+}} prev 0x{{.+}} <{{.+}}:[[@LINE-26]]:3, col:41> col:19 TestFunctionTemplate 'void (testFunctionTemplateDecl::B)' + // CHECK: FunctionDecl 0x{{.+}} prev 0x{{.+}} <{{.+}}:[[@LINE-32]]:3, col:41> col:19 TestFunctionTemplate 'void (testFunctionTemplateDecl::B)' // CHECK-NEXT: |-TemplateArgument type 'testFunctionTemplateDecl::B' + // CHECK-NEXT: | `-RecordType 0{{.+}} 'testFunctionTemplateDecl::B' + // CHECK-NEXT: | `-CXXRecord 0x{{.+}} 'B' // CHECK-NEXT: `-ParmVarDecl 0x{{.+}} col:41 'testFunctionTemplateDecl::B' @@ -311,19 +319,21 @@ namespace testClassTemplateDecl { // CHECK-NEXT: | | |-MoveAssignment // CHECK-NEXT: | | `-Destructor non_trivial user_declared // CHECK-NEXT: | |-TemplateArgument type 'testClassTemplateDecl::A' +// CHECK-NEXT: | | `-RecordType 0{{.+}} 'testClassTemplateDecl::A' +// CHECK-NEXT: | | `-CXXRecord 0x{{.+}} 'A' // CHECK-NEXT: | |-CXXRecordDecl 0x{{.+}} prev 0x{{.+}} col:30 implicit class TestClassTemplate -// CHECK-NEXT: | |-AccessSpecDecl 0x{{.+}} col:3 public -// CHECK-NEXT: | |-CXXConstructorDecl 0x{{.+}} col:5 used TestClassTemplate 'void ()' -// CHECK-NEXT: | |-CXXDestructorDecl 0x{{.+}} col:5 used ~TestClassTemplate 'void () noexcept' -// CHECK-NEXT: | |-CXXMethodDecl 0x{{.+}} col:9 j 'int ()' -// CHECK-NEXT: | |-FieldDecl 0x{{.+}} col:9 i 'int' -// CHECK-NEXT: | `-CXXConstructorDecl 0x{{.+}} col:30 implicit constexpr TestClassTemplate 'void (const testClassTemplateDecl::TestClassTemplate &)' inline default trivial noexcept-unevaluated 0x{{.+}} +// CHECK-NEXT: | |-AccessSpecDecl 0x{{.+}} col:3 public +// CHECK-NEXT: | |-CXXConstructorDecl 0x{{.+}} col:5 used TestClassTemplate 'void ()' +// CHECK-NEXT: | |-CXXDestructorDecl 0x{{.+}} col:5 used ~TestClassTemplate 'void () noexcept' +// CHECK-NEXT: | |-CXXMethodDecl 0x{{.+}} col:9 j 'int ()' +// CHECK-NEXT: | |-FieldDecl 0x{{.+}} col:9 i 'int' +// CHECK-NEXT: | `-CXXConstructorDecl 0x{{.+}} col:30 implicit constexpr TestClassTemplate 'void (const testClassTemplateDecl::TestClassTemplate &)' inline default trivial noexcept-unevaluated 0x{{.+}} // CHECK-NEXT: | `-ParmVarDecl 0x{{.+}} col:30 'const testClassTemplateDecl::TestClassTemplate &' // CHECK-NEXT: |-ClassTemplateSpecialization 0x{{.+}} 'TestClassTemplate' // CHECK-NEXT: |-ClassTemplateSpecialization 0x{{.+}} 'TestClassTemplate' // CHECK-NEXT: `-ClassTemplateSpecialization 0x{{.+}} 'TestClassTemplate' -// CHECK: ClassTemplateSpecializationDecl 0x{{.+}} <{{.+}}:[[@LINE-65]]:3, line:[[@LINE-63]]:3> line:[[@LINE-65]]:20 class TestClassTemplate definition +// CHECK: ClassTemplateSpecializationDecl 0x{{.+}} <{{.+}}:[[@LINE-67]]:3, line:[[@LINE-65]]:3> line:[[@LINE-67]]:20 class TestClassTemplate definition // CHECK-NEXT: |-DefinitionData pass_in_registers standard_layout trivially_copyable trivial literal // CHECK-NEXT: | |-DefaultConstructor exists trivial needs_implicit // CHECK-NEXT: | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param @@ -332,8 +342,10 @@ namespace testClassTemplateDecl { // CHECK-NEXT: | |-MoveAssignment exists simple trivial needs_implicit // CHECK-NEXT: | `-Destructor simple irrelevant trivial needs_implicit // CHECK-NEXT: |-TemplateArgument type 'testClassTemplateDecl::B' +// CHECK-NEXT: | `-RecordType 0{{.+}} 'testClassTemplateDecl::B' +// CHECK-NEXT: | `-CXXRecord 0x{{.+}} 'B' // CHECK-NEXT: |-CXXRecordDecl 0x{{.+}} col:20 implicit class TestClassTemplate -// CHECK-NEXT: `-FieldDecl 0x{{.+}} col:9 j 'int' +// CHECK-NEXT: `-FieldDecl 0x{{.+}} col:9 j 'int' // CHECK: ClassTemplateSpecializationDecl 0x{{.+}} <{{.+}}:{{.*}}:3, col:44> col:25 class TestClassTemplate definition // CHECK-NEXT: |-DefinitionData standard_layout has_user_declared_ctor can_const_default_init @@ -344,14 +356,16 @@ namespace testClassTemplateDecl { // CHECK-NEXT: | |-MoveAssignment // CHECK-NEXT: | `-Destructor non_trivial user_declared // CHECK-NEXT: |-TemplateArgument type 'testClassTemplateDecl::C' -// CHECK-NEXT: |-CXXRecordDecl 0x{{.+}} prev 0x{{.+}} col:30 implicit class TestClassTemplate -// CHECK-NEXT: |-AccessSpecDecl 0x{{.+}} col:3 public -// CHECK-NEXT: |-CXXConstructorDecl 0x{{.+}} col:5 TestClassTemplate 'void ()' -// CHECK-NEXT: |-CXXDestructorDecl 0x{{.+}} col:5 ~TestClassTemplate 'void ()' noexcept-unevaluated 0x{{.+}} -// CHECK-NEXT: |-CXXMethodDecl 0x{{.+}} col:9 j 'int ()' -// CHECK-NEXT: `-FieldDecl 0x{{.+}} col:9 i 'int' - -// CHECK: ClassTemplateSpecializationDecl 0x{{.+}} <{{.+}}:[[@LINE-85]]:3, col:37> col:18 class TestClassTemplate definition +// CHECK-NEXT: | `-RecordType 0{{.+}} 'testClassTemplateDecl::C' +// CHECK-NEXT: | `-CXXRecord 0x{{.+}} 'C' +// CHECK-NEXT: |-CXXRecordDecl 0x{{.+}} prev 0x{{.+}} col:30 implicit class TestClassTemplate +// CHECK-NEXT: |-AccessSpecDecl 0x{{.+}} col:3 public +// CHECK-NEXT: |-CXXConstructorDecl 0x{{.+}} col:5 TestClassTemplate 'void ()' +// CHECK-NEXT: |-CXXDestructorDecl 0x{{.+}} col:5 ~TestClassTemplate 'void ()' noexcept-unevaluated 0x{{.+}} +// CHECK-NEXT: |-CXXMethodDecl 0x{{.+}} col:9 j 'int ()' +// CHECK-NEXT: `-FieldDecl 0x{{.+}} col:9 i 'int' + +// CHECK: ClassTemplateSpecializationDecl 0x{{.+}} <{{.+}}:[[@LINE-91]]:3, col:37> col:18 class TestClassTemplate definition // CHECK-NEXT: |-DefinitionData standard_layout has_user_declared_ctor can_const_default_init // CHECK-NEXT: | |-DefaultConstructor exists non_trivial user_provided // CHECK-NEXT: | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param @@ -360,17 +374,19 @@ namespace testClassTemplateDecl { // CHECK-NEXT: | |-MoveAssignment // CHECK-NEXT: | `-Destructor non_trivial user_declared // CHECK-NEXT: |-TemplateArgument type 'testClassTemplateDecl::D' -// CHECK-NEXT: |-CXXRecordDecl 0x{{.+}} prev 0x{{.+}} col:30 implicit class TestClassTemplate -// CHECK-NEXT: |-AccessSpecDecl 0x{{.+}} col:3 public -// CHECK-NEXT: |-CXXConstructorDecl 0x{{.+}} col:5 TestClassTemplate 'void ()' -// CHECK-NEXT: |-CXXDestructorDecl 0x{{.+}} col:5 ~TestClassTemplate 'void ()' noexcept-unevaluated 0x{{.+}} -// CHECK-NEXT: |-CXXMethodDecl 0x{{.+}} col:9 j 'int ()' -// CHECK-NEXT: `-FieldDecl 0x{{.+}} col:9 i 'int' - -// CHECK: ClassTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-98]]:3, line:[[@LINE-96]]:3> line:[[@LINE-98]]:44 TestClassTemplatePartial +// CHECK-NEXT: | `-RecordType 0{{.+}} 'testClassTemplateDecl::D' +// CHECK-NEXT: | `-CXXRecord 0x{{.+}} 'D' +// CHECK-NEXT: |-CXXRecordDecl 0x{{.+}} prev 0x{{.+}} col:30 implicit class TestClassTemplate +// CHECK-NEXT: |-AccessSpecDecl 0x{{.+}} col:3 public +// CHECK-NEXT: |-CXXConstructorDecl 0x{{.+}} col:5 TestClassTemplate 'void ()' +// CHECK-NEXT: |-CXXDestructorDecl 0x{{.+}} col:5 ~TestClassTemplate 'void ()' noexcept-unevaluated 0x{{.+}} +// CHECK-NEXT: |-CXXMethodDecl 0x{{.+}} col:9 j 'int ()' +// CHECK-NEXT: `-FieldDecl 0x{{.+}} col:9 i 'int' + +// CHECK: ClassTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-106]]:3, line:[[@LINE-104]]:3> line:[[@LINE-106]]:44 TestClassTemplatePartial // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} col:21 typename depth 0 index 0 T1 // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} col:34 typename depth 0 index 1 T2 -// CHECK-NEXT: `-CXXRecordDecl 0x{{.+}} line:[[@LINE-101]]:44 class TestClassTemplatePartial definition +// CHECK-NEXT: `-CXXRecordDecl 0x{{.+}} line:[[@LINE-109]]:44 class TestClassTemplatePartial definition // CHECK-NEXT: |-DefinitionData standard_layout trivially_copyable trivial literal // CHECK-NEXT: | |-DefaultConstructor exists trivial needs_implicit // CHECK-NEXT: | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param @@ -379,9 +395,9 @@ namespace testClassTemplateDecl { // CHECK-NEXT: | |-MoveAssignment exists simple trivial needs_implicit // CHECK-NEXT: | `-Destructor simple irrelevant trivial needs_implicit // CHECK-NEXT: |-CXXRecordDecl 0x{{.+}} col:44 implicit class TestClassTemplatePartial -// CHECK-NEXT: `-FieldDecl 0x{{.+}} col:9 i 'int' +// CHECK-NEXT: `-FieldDecl 0x{{.+}} col:9 i 'int' -// CHECK: ClassTemplatePartialSpecializationDecl 0x{{.+}} <{{.+}}:[[@LINE-109]]:3, line:[[@LINE-107]]:3> line:[[@LINE-109]]:31 class TestClassTemplatePartial definition +// CHECK: ClassTemplatePartialSpecializationDecl 0x{{.+}} <{{.+}}:[[@LINE-117]]:3, line:[[@LINE-115]]:3> line:[[@LINE-117]]:31 class TestClassTemplatePartial definition // CHECK-NEXT: |-DefinitionData standard_layout trivially_copyable trivial literal // CHECK-NEXT: | |-DefaultConstructor exists trivial needs_implicit // CHECK-NEXT: | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param @@ -390,20 +406,25 @@ namespace testClassTemplateDecl { // CHECK-NEXT: | |-MoveAssignment exists simple trivial needs_implicit // CHECK-NEXT: | `-Destructor simple irrelevant trivial needs_implicit // CHECK-NEXT: |-TemplateArgument type 'type-parameter-0-0' +// CHECK-NEXT: | `-TemplateTypeParmType 0x{{.+}} 'type-parameter-0-0' dependent depth 0 index 0 // CHECK-NEXT: |-TemplateArgument type 'testClassTemplateDecl::A' +// CHECK-NEXT: | `-RecordType 0x{{.+}} 'testClassTemplateDecl::A' +// CHECK-NEXT: | `-CXXRecord 0x{{.+}} 'A' // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} col:21 referenced typename depth 0 index 0 T1 // CHECK-NEXT: |-CXXRecordDecl 0x{{.+}} col:31 implicit class TestClassTemplatePartial -// CHECK-NEXT: `-FieldDecl 0x{{.+}} col:9 j 'int' +// CHECK-NEXT: `-FieldDecl 0x{{.+}} col:9 j 'int' -// CHECK: ClassTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-119]]:3, col:37> col:37 TestTemplateDefaultType +// CHECK: ClassTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-130]]:3, col:37> col:37 TestTemplateDefaultType // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} col:21 typename depth 0 index 0 T // CHECK-NEXT: | `-TemplateArgument type 'int' +// CHECK-NEXT: | `-BuiltinType 0x{{.+}} 'int' // CHECK-NEXT: `-CXXRecordDecl 0x{{.+}} col:37 struct TestTemplateDefaultType -// CHECK: ClassTemplateDecl 0x{{.+}} prev 0x{{.+}} <{{.+}}:[[@LINE-123]]:3, col:57> col:31 TestTemplateDefaultType +// CHECK: ClassTemplateDecl 0x{{.+}} prev 0x{{.+}} <{{.+}}:[[@LINE-135]]:3, col:57> col:31 TestTemplateDefaultType // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} col:21 typename depth 0 index 0 T // CHECK-NEXT: | `-TemplateArgument type 'int' -// CHECK-NEXT: | `-inherited from TemplateTypeParm 0x{{.+}} 'T' +// CHECK-NEXT: | |-inherited from TemplateTypeParm 0x{{.+}} 'T' +// CHECK-NEXT: | `-BuiltinType 0x{{.+}} 'int' // CHECK-NEXT: `-CXXRecordDecl 0x{{.+}} prev 0x{{.+}} col:31 struct TestTemplateDefaultType definition // CHECK-NEXT: |-DefinitionData empty aggregate standard_layout trivially_copyable pod trivial literal has_constexpr_non_copy_move_ctor can_const_default_init // CHECK-NEXT: | |-DefaultConstructor exists trivial constexpr needs_implicit defaulted_is_constexpr @@ -414,7 +435,7 @@ namespace testClassTemplateDecl { // CHECK-NEXT: | `-Destructor simple irrelevant trivial needs_implicit // CHECK-NEXT: `-CXXRecordDecl 0x{{.+}} col:31 implicit struct TestTemplateDefaultType -// CHECK: ClassTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-135]]:3, col:31> col:31 TestTemplateDefaultNonType +// CHECK: ClassTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-148]]:3, col:31> col:31 TestTemplateDefaultNonType // CHECK-NEXT: |-NonTypeTemplateParmDecl 0x{{.+}} col:16 'int' depth 0 index 0 I // CHECK-NEXT: | `-TemplateArgument expr // CHECK-NEXT: | `-ConstantExpr 0x{{.+}} 'int' @@ -456,9 +477,11 @@ namespace testCanonicalTemplate { // CHECK-NEXT: | `-ParmVarDecl 0x{{.*}} col:51 'T' // CHECK-NEXT: `-FunctionDecl 0x{{.*}} col:29 used TestFunctionTemplate 'void (testCanonicalTemplate::A)' // CHECK-NEXT: |-TemplateArgument type 'testCanonicalTemplate::A' + // CHECK-NEXT: | `-RecordType 0x{{.+}} 'testCanonicalTemplate::A' + // CHECK-NEXT: | `-CXXRecord 0x{{.+}} 'A' // CHECK-NEXT: `-ParmVarDecl 0x{{.*}} col:51 'testCanonicalTemplate::A':'testCanonicalTemplate::A' - // CHECK: FunctionTemplateDecl 0x{{.+}} prev 0x{{.+}} <{{.+}}:[[@LINE-10]]:3, col:51> col:29 TestFunctionTemplate + // CHECK: FunctionTemplateDecl 0x{{.+}} prev 0x{{.+}} <{{.+}}:[[@LINE-12]]:3, col:51> col:29 TestFunctionTemplate // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} col:21 referenced typename depth 0 index 0 T // CHECK-NEXT: |-FunctionDecl{{.*}} 0x{{.+}} prev 0x{{.+}} col:29 TestFunctionTemplate 'void (T)' // CHECK-NEXT: | `-ParmVarDecl 0x{{.+}} col:51 'T' @@ -493,13 +516,15 @@ namespace testCanonicalTemplate { // CHECK-NEXT: | |-MoveAssignment exists simple trivial needs_implicit // CHECK-NEXT: | `-Destructor simple irrelevant trivial needs_implicit // CHECK-NEXT: |-TemplateArgument type 'testCanonicalTemplate::A' + // CHECK-NEXT: | `-RecordType 0x{{.+}} 'testCanonicalTemplate::A' + // CHECK-NEXT: | `-CXXRecord 0x{{.+}} 'A' // CHECK-NEXT: |-CXXRecordDecl 0x{{.+}} prev 0x{{.+}} col:31 implicit class TestClassTemplate - // CHECK-NEXT: |-FriendDecl 0x{{.+}} col:40 + // CHECK-NEXT: |-FriendDecl 0x{{.+}} col:40 // CHECK-NEXT: | `-ClassTemplateDecl 0x{{.+}} parent 0x{{.+}} prev 0x{{.+}} col:40 TestClassTemplate // CHECK-NEXT: | |-TemplateTypeParmDecl 0x{{.+}} col:23 typename depth 0 index 0 T2 // CHECK-NEXT: | |-CXXRecordDecl 0x{{.+}} parent 0x{{.+}} prev 0x{{.+}} col:40 class TestClassTemplate // CHECK-NEXT: | `-ClassTemplateSpecialization 0x{{.+}} 'TestClassTemplate' - // CHECK-NEXT: |-CXXConstructorDecl 0x{{.+}} col:31 implicit used constexpr TestClassTemplate 'void () noexcept' inline default trivial + // CHECK-NEXT: |-CXXConstructorDecl 0x{{.+}} col:31 implicit used constexpr TestClassTemplate 'void () noexcept' inline default trivial // CHECK-NEXT: | `-CompoundStmt 0x{{.+}} // CHECK-NEXT: |-CXXConstructorDecl 0x{{.+}} col:31 implicit constexpr TestClassTemplate 'void (const testCanonicalTemplate::TestClassTemplate &)' inline default trivial noexcept-unevaluated 0x{{.+}} // CHECK-NEXT: | `-ParmVarDecl 0x{{.+}} col:31 'const testCanonicalTemplate::TestClassTemplate &' @@ -524,6 +549,8 @@ namespace testCanonicalTemplate { // CHECK-NEXT: | |-MoveAssignment exists simple trivial needs_implicit // CHECK-NEXT: | `-Destructor simple irrelevant trivial needs_implicit // CHECK-NEXT: |-TemplateArgument type 'testCanonicalTemplate::A' + // CHECK-NEXT: | `-RecordType 0x{{.+}} 'testCanonicalTemplate::A' + // CHECK-NEXT: | `-CXXRecord 0x{{.+}} 'A' // CHECK-NEXT: |-CXXRecordDecl 0x{{.+}} prev 0x{{.+}} col:31 implicit class TestClassTemplate2 // CHECK-NEXT: |-CXXConstructorDecl 0x{{.+}} col:31 implicit used constexpr TestClassTemplate2 'void () noexcept' inline default trivial // CHECK-NEXT: | `-CompoundStmt 0x{{.+}} @@ -532,14 +559,14 @@ namespace testCanonicalTemplate { // CHECK-NEXT: `-CXXConstructorDecl 0x{{.+}} col:31 implicit constexpr TestClassTemplate2 'void (testCanonicalTemplate::TestClassTemplate2 &&)' inline default trivial noexcept-unevaluated 0x{{.+}} // CHECK-NEXT: `-ParmVarDecl 0x{{.+}} col:31 'testCanonicalTemplate::TestClassTemplate2 &&' - // CHECK: ClassTemplateDecl 0x{{.+}} prev 0x{{.+}} <{{.+}}:[[@LINE-24]]:3, col:31> col:31 TestClassTemplate2 + // CHECK: ClassTemplateDecl 0x{{.+}} prev 0x{{.+}} <{{.+}}:[[@LINE-26]]:3, col:31> col:31 TestClassTemplate2 // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} col:21 typename depth 0 index 0 T1 // CHECK-NEXT: |-CXXRecordDecl 0x{{.+}} prev 0x{{.+}} col:31 class TestClassTemplate2 // CHECK-NEXT: `-ClassTemplateSpecialization 0x{{.+}} 'TestClassTemplate2' - // CHECK: ClassTemplateDecl 0x{{.+}} prev 0x{{.+}} <{{.+}}:[[@LINE-28]]:3, line:[[@LINE-27]]:3> line:[[@LINE-28]]:31 TestClassTemplate2 + // CHECK: ClassTemplateDecl 0x{{.+}} prev 0x{{.+}} <{{.+}}:[[@LINE-30]]:3, line:[[@LINE-29]]:3> line:[[@LINE-30]]:31 TestClassTemplate2 // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} col:21 typename depth 0 index 0 T1 - // CHECK-NEXT: |-CXXRecordDecl 0x{{.+}} prev 0x{{.+}} line:[[@LINE-30]]:31 class TestClassTemplate2 definition + // CHECK-NEXT: |-CXXRecordDecl 0x{{.+}} prev 0x{{.+}} line:[[@LINE-32]]:31 class TestClassTemplate2 definition // CHECK-NEXT: | |-DefinitionData empty aggregate standard_layout trivially_copyable pod trivial literal has_constexpr_non_copy_move_ctor can_const_default_init // CHECK-NEXT: | | |-DefaultConstructor exists trivial constexpr needs_implicit defaulted_is_constexpr // CHECK-NEXT: | | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param @@ -567,22 +594,25 @@ namespace testCanonicalTemplate { // CHECK-NEXT: |-VarDecl 0x{{.+}} col:43 TestVarTemplate 'const T' static // CHECK-NEXT: |-VarTemplateSpecializationDecl 0x{{.+}} parent 0x{{.+}} prev 0x{{.+}} col:14 referenced TestVarTemplate 'const int':'const int' cinit // CHECK-NEXT: | |-TemplateArgument type 'int' + // CHECK-NEXT: | | `-BuiltinType 0x{{.+}} 'int' // CHECK-NEXT: | `-InitListExpr 0x{{.+}} 'int':'int' - // CHECK-NEXT: `-VarTemplateSpecializationDecl 0x{{.+}} col:43 referenced TestVarTemplate 'const int':'const int' static + // CHECK-NEXT: `-VarTemplateSpecializationDecl 0x{{.+}} col:43 referenced TestVarTemplate 'const int':'const int' static // CHECK-NEXT: `-TemplateArgument type 'int' - // CHECK: VarTemplateSpecializationDecl 0x{{.+}} <{{.+}}:[[@LINE-20]]:28, col:43> col:43 referenced TestVarTemplate 'const int':'const int' static + // CHECK: VarTemplateSpecializationDecl 0x{{.+}} <{{.+}}:[[@LINE-21]]:28, col:43> col:43 referenced TestVarTemplate 'const int':'const int' static // CHECK-NEXT:`-TemplateArgument type 'int' + // CHECK-NEXT: `-BuiltinType 0x{{.+}} 'int' - // CHECK: VarTemplateDecl 0x{{.+}} parent 0x{{.+}} prev 0x{{.+}} <{{.+}}:[[@LINE-21]]:3, line:[[@LINE-20]]:34> col:14 TestVarTemplate - // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} col:21 referenced typename depth 0 index 0 T - // CHECK-NEXT: |-VarDecl 0x{{.+}} parent 0x{{.+}} prev 0x{{.+}} col:14 TestVarTemplate 'const T' cinit + // CHECK: VarTemplateDecl 0x{{.+}} parent 0x{{.+}} prev 0x{{.+}} <{{.+}}:[[@LINE-23]]:3, line:[[@LINE-22]]:34> col:14 TestVarTemplate + // CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} col:21 referenced typename depth 0 index 0 T + // CHECK-NEXT: |-VarDecl 0x{{.+}} parent 0x{{.+}} prev 0x{{.+}} col:14 TestVarTemplate 'const T' cinit // CHECK-NEXT: | `-InitListExpr 0x{{.+}} 'void' // CHECK-NEXT: |-VarTemplateSpecialization 0x{{.+}} 'TestVarTemplate' 'const int':'const int' // CHECK-NEXT: `-VarTemplateSpecialization 0x{{.+}} 'TestVarTemplate' 'const int':'const int' - // CHECK: VarTemplateSpecializationDecl 0x{{.+}} parent 0x{{.+}} prev 0x{{.+}} <{{.+}}:[[@LINE-27]]:3, col:34> col:14 referenced TestVarTemplate 'const int':'const int' cinit + // CHECK: VarTemplateSpecializationDecl 0x{{.+}} parent 0x{{.+}} prev 0x{{.+}} <{{.+}}:[[@LINE-29]]:3, col:34> col:14 referenced TestVarTemplate 'const int':'const int' cinit // CHECK-NEXT: |-TemplateArgument type 'int' + // CHECK-NEXT: | `-BuiltinType 0x{{.+}} 'int' // CHECK-NEXT: `-InitListExpr 0x{{.+}} 'int':'int' } diff --git a/clang/test/AST/ast-dump-openmp-begin-declare-variant_template_1.cpp b/clang/test/AST/ast-dump-openmp-begin-declare-variant_template_1.cpp index 6a663d5..6d36c1b 100644 --- a/clang/test/AST/ast-dump-openmp-begin-declare-variant_template_1.cpp +++ b/clang/test/AST/ast-dump-openmp-begin-declare-variant_template_1.cpp @@ -118,7 +118,7 @@ int test() { // CHECK-NEXT: | | `-IntegerLiteral [[ADDR_58:0x[a-z0-9]*]] 'int' 0 // CHECK-NEXT: | `-FunctionDecl [[ADDR_59:0x[a-z0-9]*]] line:37:5 used test1 'int ({{.*}})' // CHECK-NEXT: | |-TemplateArgument type 'double' -// CHECK-NEXT: | `-CompoundStmt [[ADDR_60:0x[a-z0-9]*]] +// CHECK: | `-CompoundStmt [[ADDR_60:0x[a-z0-9]*]] // CHECK-NEXT: | `-ReturnStmt [[ADDR_61:0x[a-z0-9]*]] // CHECK-NEXT: | `-PseudoObjectExpr [[ADDR_62:0x[a-z0-9]*]] 'int' // CHECK-NEXT: | |-CallExpr [[ADDR_63:0x[a-z0-9]*]] 'int' diff --git a/clang/test/AST/ast-dump-template-decls-json.cpp b/clang/test/AST/ast-dump-template-decls-json.cpp index 658358c..f074d6f 100644 --- a/clang/test/AST/ast-dump-template-decls-json.cpp +++ b/clang/test/AST/ast-dump-template-decls-json.cpp @@ -597,13 +597,31 @@ void V::f() {} // CHECK-NEXT: "kind": "TemplateArgument", // CHECK-NEXT: "type": { // CHECK-NEXT: "qualType": "float" -// CHECK-NEXT: } +// CHECK-NEXT: }, +// CHECK-NEXT: "inner": [ +// CHECK-NEXT: { +// CHECK-NEXT: "id": "0x{{.*}}", +// CHECK-NEXT: "kind": "BuiltinType", +// CHECK-NEXT: "type": { +// CHECK-NEXT: "qualType": "float" +// CHECK-NEXT: } +// CHECK-NEXT: } +// CHECK-NEXT: ] // CHECK-NEXT: }, // CHECK-NEXT: { // CHECK-NEXT: "kind": "TemplateArgument", // CHECK-NEXT: "type": { // CHECK-NEXT: "qualType": "int" -// CHECK-NEXT: } +// CHECK-NEXT: }, +// CHECK-NEXT: "inner": [ +// CHECK-NEXT: { +// CHECK-NEXT: "id": "0x{{.*}}", +// CHECK-NEXT: "kind": "BuiltinType", +// CHECK-NEXT: "type": { +// CHECK-NEXT: "qualType": "int" +// CHECK-NEXT: } +// CHECK-NEXT: } +// CHECK-NEXT: ] // CHECK-NEXT: }, // CHECK-NEXT: { // CHECK-NEXT: "id": "0x{{.*}}", @@ -1120,7 +1138,16 @@ void V::f() {} // CHECK-NEXT: "kind": "TemplateArgument", // CHECK-NEXT: "type": { // CHECK-NEXT: "qualType": "int" -// CHECK-NEXT: } +// CHECK-NEXT: }, +// CHECK-NEXT: "inner": [ +// CHECK-NEXT: { +// CHECK-NEXT: "id": "0x{{.*}}", +// CHECK-NEXT: "kind": "BuiltinType", +// CHECK-NEXT: "type": { +// CHECK-NEXT: "qualType": "int" +// CHECK-NEXT: } +// CHECK-NEXT: } +// CHECK-NEXT: ] // CHECK-NEXT: } // CHECK-NEXT: ] // CHECK-NEXT: }, @@ -1238,7 +1265,16 @@ void V::f() {} // CHECK-NEXT: "kind": "TemplateArgument", // CHECK-NEXT: "type": { // CHECK-NEXT: "qualType": "void" -// CHECK-NEXT: } +// CHECK-NEXT: }, +// CHECK-NEXT: "inner": [ +// CHECK-NEXT: { +// CHECK-NEXT: "id": "0x{{.*}}", +// CHECK-NEXT: "kind": "BuiltinType", +// CHECK-NEXT: "type": { +// CHECK-NEXT: "qualType": "void" +// CHECK-NEXT: } +// CHECK-NEXT: } +// CHECK-NEXT: ] // CHECK-NEXT: } // CHECK-NEXT: ] // CHECK-NEXT: }, @@ -1511,7 +1547,16 @@ void V::f() {} // CHECK-NEXT: "kind": "TemplateArgument", // CHECK-NEXT: "type": { // CHECK-NEXT: "qualType": "int" -// CHECK-NEXT: } +// CHECK-NEXT: }, +// CHECK-NEXT: "inner": [ +// CHECK-NEXT: { +// CHECK-NEXT: "id": "0x{{.*}}", +// CHECK-NEXT: "kind": "BuiltinType", +// CHECK-NEXT: "type": { +// CHECK-NEXT: "qualType": "int" +// CHECK-NEXT: } +// CHECK-NEXT: } +// CHECK-NEXT: ] // CHECK-NEXT: }, // CHECK-NEXT: { // CHECK-NEXT: "id": "0x{{.*}}", @@ -1799,13 +1844,38 @@ void V::f() {} // CHECK-NEXT: "kind": "TemplateArgument", // CHECK-NEXT: "type": { // CHECK-NEXT: "qualType": "type-parameter-0-0" -// CHECK-NEXT: } +// CHECK-NEXT: }, +// CHECK-NEXT: "inner": [ +// CHECK-NEXT: { +// CHECK-NEXT: "id": "0x{{.*}}", +// CHECK-NEXT: "kind": "TemplateTypeParmType", +// CHECK-NEXT: "type": { +// CHECK-NEXT: "qualType": "type-parameter-0-0" +// CHECK-NEXT: }, +// CHECK-NEXT: "isDependent": true, +// CHECK-NEXT: "isInstantiationDependent": true, +// CHECK-NEXT: "depth": 0, +// CHECK-NEXT: "index": 0, +// CHECK-NEXT: "decl": { +// CHECK-NEXT: "id": "0x0" +// CHECK-NEXT: } +// CHECK-NEXT: } +// CHECK-NEXT: ] // CHECK-NEXT: }, // CHECK-NEXT: { // CHECK-NEXT: "kind": "TemplateArgument", // CHECK-NEXT: "type": { // CHECK-NEXT: "qualType": "int" -// CHECK-NEXT: } +// CHECK-NEXT: }, +// CHECK-NEXT: "inner": [ +// CHECK-NEXT: { +// CHECK-NEXT: "id": "0x{{.*}}", +// CHECK-NEXT: "kind": "BuiltinType", +// CHECK-NEXT: "type": { +// CHECK-NEXT: "qualType": "int" +// CHECK-NEXT: } +// CHECK-NEXT: } +// CHECK-NEXT: ] // CHECK-NEXT: }, // CHECK-NEXT: { // CHECK-NEXT: "id": "0x{{.*}}", diff --git a/clang/test/AST/ast-dump-template-decls.cpp b/clang/test/AST/ast-dump-template-decls.cpp index 29d2335..e58731a 100644 --- a/clang/test/AST/ast-dump-template-decls.cpp +++ b/clang/test/AST/ast-dump-template-decls.cpp @@ -79,8 +79,8 @@ 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 +// CHECK: TemplateArgument type 'int' +// CHECK: TemplateTypeParmDecl 0x{{[^ ]*}} col:20 referenced typename depth 0 index 0 Ty struct S {}; template diff --git a/clang/test/AST/float16.cpp b/clang/test/AST/float16.cpp index c886aa9..807289a 100644 --- a/clang/test/AST/float16.cpp +++ b/clang/test/AST/float16.cpp @@ -178,7 +178,7 @@ template C func1t(C arg) { //CHECK-NEXT: | | `-FloatingLiteral {{.*}} '_Float16' 2.000000e+00 //CHECK-NEXT: | `-FunctionDecl {{.*}} used func1t '_Float16 (_Float16)' //CHECK-NEXT: | |-TemplateArgument type '_Float16' -//CHECK-NEXT: | |-ParmVarDecl {{.*}} used arg '_Float16':'_Float16' +//CHECK: | |-ParmVarDecl {{.*}} used arg '_Float16':'_Float16' //CHECK-NEXT: | `-CompoundStmt //CHECK-NEXT: | `-ReturnStmt //CHECK-NEXT: | `-BinaryOperator {{.*}} '_Float16' '*' diff --git a/clang/unittests/AST/ASTTraverserTest.cpp b/clang/unittests/AST/ASTTraverserTest.cpp index 5585238..6d3d833 100644 --- a/clang/unittests/AST/ASTTraverserTest.cpp +++ b/clang/unittests/AST/ASTTraverserTest.cpp @@ -244,6 +244,7 @@ FullComment verifyWithDynNode(TA, R"cpp( TemplateArgument +`-BuiltinType )cpp"); Func = getFunctionNode(AST.get(), "parmvardecl_attr");