[PATCH] D85282: [Concepts] Dump template arguments for immediately declared constraint.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 5 01:26:26 PDT 2020
hokein created this revision.
hokein added a reviewer: nridge.
Herald added a subscriber: kristof.beyls.
Herald added a project: clang.
hokein requested review of this revision.
The template arguments were dumped as part of the TemplateTypeParmDecl, which
was incorrect.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D85282
Files:
clang/include/clang/AST/ASTNodeTraverser.h
clang/lib/AST/TextNodeDumper.cpp
clang/test/AST/ast-dump-concepts.cpp
Index: clang/test/AST/ast-dump-concepts.cpp
===================================================================
--- clang/test/AST/ast-dump-concepts.cpp
+++ clang/test/AST/ast-dump-concepts.cpp
@@ -15,8 +15,12 @@
template <typename T>
struct Foo {
// CHECK: TemplateTypeParmDecl {{.*}} referenced Concept {{.*}} 'binary_concept'
- // CHECK-NEXT: |-ConceptSpecializationExpr {{.*}} <col:13, col:31> '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 <binary_concept<int> R>
Foo(R);
@@ -25,11 +29,11 @@
template <unary_concept R>
Foo(R);
- // CHECK: FunctionTemplateDecl {{.*}} <line:29:3, line:30:39> {{.*}} Foo<T>
+ // CHECK: FunctionTemplateDecl {{.*}} <line:[[@LINE+1]]:3, line:[[@LINE+2]]:39> {{.*}} Foo<T>
template <typename R>
Foo(R, int) requires unary_concept<R>;
- // CHECK: FunctionTemplateDecl {{.*}} <line:33:3, line:35:3> {{.*}} Foo<T>
+ // CHECK: FunctionTemplateDecl {{.*}} <line:[[@LINE+1]]:3, line:[[@LINE+3]]:3> {{.*}} Foo<T>
template <typename R>
Foo(R, char) requires unary_concept<R> {
}
Index: clang/lib/AST/TextNodeDumper.cpp
===================================================================
--- clang/lib/AST/TextNodeDumper.cpp
+++ clang/lib/AST/TextNodeDumper.cpp
@@ -2000,7 +2000,6 @@
dumpBareDeclRef(TC->getFoundDecl());
OS << ")";
}
- AddChild([=] { Visit(TC->getImmediatelyDeclaredConstraint()); });
} else if (D->wasDeclaredWithTypename())
OS << " typename";
else
Index: clang/include/clang/AST/ASTNodeTraverser.h
===================================================================
--- clang/include/clang/AST/ASTNodeTraverser.h
+++ 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<TypeDecl>(D->getUnderlyingDecl()))
Visit(TD->getTypeForDecl());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85282.283160.patch
Type: text/x-patch
Size: 3097 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200805/a3fca149/attachment.bin>
More information about the cfe-commits
mailing list