diff --git a/clang/include/clang/AST/ASTNodeTraverser.h b/clang/include/clang/AST/ASTNodeTraverser.h --- a/clang/include/clang/AST/ASTNodeTraverser.h +++ b/clang/include/clang/AST/ASTNodeTraverser.h @@ -543,9 +543,7 @@ void VisitTemplateTypeParmDecl(const TemplateTypeParmDecl *D) { if (const auto *TC = D->getTypeConstraint()) - if (TC->hasExplicitTemplateArgs()) - for (const auto &ArgLoc : TC->getTemplateArgsAsWritten()->arguments()) - dumpTemplateArgumentLoc(ArgLoc); + Visit(TC->getImmediatelyDeclaredConstraint()); if (D->hasDefaultArgument()) Visit(D->getDefaultArgument(), SourceRange(), D->getDefaultArgStorage().getInheritedFrom(), @@ -574,6 +572,12 @@ Visit(D->getConstraintExpr()); } + void VisitConceptSpecializationExpr(const ConceptSpecializationExpr *CSE) { + if (CSE->hasExplicitTemplateArgs()) + for (const auto &ArgLoc : CSE->getTemplateArgsAsWritten()->arguments()) + dumpTemplateArgumentLoc(ArgLoc); + } + void VisitUsingShadowDecl(const UsingShadowDecl *D) { if (auto *TD = dyn_cast(D->getUnderlyingDecl())) Visit(TD->getTypeForDecl()); diff --git a/clang/lib/AST/TextNodeDumper.cpp b/clang/lib/AST/TextNodeDumper.cpp --- a/clang/lib/AST/TextNodeDumper.cpp +++ b/clang/lib/AST/TextNodeDumper.cpp @@ -1999,7 +1999,6 @@ dumpBareDeclRef(TC->getFoundDecl()); OS << ")"; } - AddChild([=] { Visit(TC->getImmediatelyDeclaredConstraint()); }); } else if (D->wasDeclaredWithTypename()) OS << " typename"; else diff --git a/clang/test/AST/ast-dump-concepts.cpp b/clang/test/AST/ast-dump-concepts.cpp --- a/clang/test/AST/ast-dump-concepts.cpp +++ b/clang/test/AST/ast-dump-concepts.cpp @@ -15,8 +15,12 @@ template struct Foo { // CHECK: TemplateTypeParmDecl {{.*}} referenced Concept {{.*}} 'binary_concept' - // CHECK-NEXT: |-ConceptSpecializationExpr {{.*}} 'bool' Concept {{.*}} 'binary_concept' - // CHECK-NEXT: `-TemplateArgument {{.*}} type 'int' + // CHECK-NEXT: `-ConceptSpecializationExpr {{.*}} 'bool' Concept {{.*}} 'binary_concept' + // CHECK-NEXT: |-TemplateArgument {{.*}} type 'R' + // CHECK-NEXT: | `-TemplateTypeParmType {{.*}} 'R' + // CHECK-NEXT: | `-TemplateTypeParm {{.*}} 'R' + // CHECK-NEXT: `-TemplateArgument {{.*}} type 'int' + // CHECK-NEXT: `-BuiltinType {{.*}} 'int' template R> Foo(R); @@ -25,11 +29,11 @@ template Foo(R); - // CHECK: FunctionTemplateDecl {{.*}} {{.*}} Foo + // CHECK: FunctionTemplateDecl {{.*}} {{.*}} Foo template Foo(R, int) requires unary_concept; - // CHECK: FunctionTemplateDecl {{.*}} {{.*}} Foo + // CHECK: FunctionTemplateDecl {{.*}} {{.*}} Foo template Foo(R, char) requires unary_concept { }