diff options
author | Haojian Wu <hokein.wu@gmail.com> | 2024-03-28 13:07:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-28 13:07:58 +0100 |
commit | fb8cccf88c5d04f36148ff336b6dc7c25746b1de (patch) | |
tree | 29f64cfc21113d9f96140d082e1a23adfb5df1d9 | |
parent | 896037c75ace929327e5b0bf5832157f9d81e6e7 (diff) | |
download | llvm-fb8cccf88c5d04f36148ff336b6dc7c25746b1de.zip llvm-fb8cccf88c5d04f36148ff336b6dc7c25746b1de.tar.gz llvm-fb8cccf88c5d04f36148ff336b6dc7c25746b1de.tar.bz2 |
[AST] Print the "aggregate" for aggregate deduction guide decl. (#84018)
I found this is useful for debugging purpose to identify different kind
of deduction guide decl.
-rw-r--r-- | clang/include/clang/AST/TextNodeDumper.h | 1 | ||||
-rw-r--r-- | clang/lib/AST/TextNodeDumper.cpp | 13 | ||||
-rw-r--r-- | clang/test/SemaTemplate/deduction-guide.cpp | 9 |
3 files changed, 23 insertions, 0 deletions
diff --git a/clang/include/clang/AST/TextNodeDumper.h b/clang/include/clang/AST/TextNodeDumper.h index de67f0b..efb5bfe 100644 --- a/clang/include/clang/AST/TextNodeDumper.h +++ b/clang/include/clang/AST/TextNodeDumper.h @@ -352,6 +352,7 @@ public: void VisitEnumConstantDecl(const EnumConstantDecl *D); void VisitIndirectFieldDecl(const IndirectFieldDecl *D); void VisitFunctionDecl(const FunctionDecl *D); + void VisitCXXDeductionGuideDecl(const CXXDeductionGuideDecl *D); void VisitFieldDecl(const FieldDecl *D); void VisitVarDecl(const VarDecl *D); void VisitBindingDecl(const BindingDecl *D); diff --git a/clang/lib/AST/TextNodeDumper.cpp b/clang/lib/AST/TextNodeDumper.cpp index b683eb1..413e452 100644 --- a/clang/lib/AST/TextNodeDumper.cpp +++ b/clang/lib/AST/TextNodeDumper.cpp @@ -1990,6 +1990,19 @@ void TextNodeDumper::VisitFunctionDecl(const FunctionDecl *D) { } } +void TextNodeDumper::VisitCXXDeductionGuideDecl( + const CXXDeductionGuideDecl *D) { + VisitFunctionDecl(D); + switch (D->getDeductionCandidateKind()) { + case DeductionCandidate::Normal: + case DeductionCandidate::Copy: + return; + case DeductionCandidate::Aggregate: + OS << " aggregate "; + break; + } +} + void TextNodeDumper::VisitLifetimeExtendedTemporaryDecl( const LifetimeExtendedTemporaryDecl *D) { OS << " extended by "; diff --git a/clang/test/SemaTemplate/deduction-guide.cpp b/clang/test/SemaTemplate/deduction-guide.cpp index 16c7083..0caef78 100644 --- a/clang/test/SemaTemplate/deduction-guide.cpp +++ b/clang/test/SemaTemplate/deduction-guide.cpp @@ -239,3 +239,12 @@ F s(0); // CHECK: |-InjectedClassNameType {{.*}} 'F<>' dependent // CHECK: | `-CXXRecord {{.*}} 'F' // CHECK: `-TemplateTypeParmType {{.*}} 'type-parameter-0-1' dependent depth 0 index 1 + +template<typename T> +struct G { T t; }; + +G g = {1}; +// CHECK-LABEL: Dumping <deduction guide for G>: +// CHECK: FunctionTemplateDecl +// CHECK: |-CXXDeductionGuideDecl {{.*}} implicit <deduction guide for G> 'auto (T) -> G<T>' aggregate +// CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used <deduction guide for G> 'auto (int) -> G<int>' implicit_instantiation aggregate |