https://github.com/hokein updated 
https://github.com/llvm/llvm-project/pull/84018

>From 63e1f39e9580f4b33fcd86572aea70bf46edb264 Mon Sep 17 00:00:00 2001
From: Haojian Wu <hokein...@gmail.com>
Date: Tue, 5 Mar 2024 14:50:23 +0100
Subject: [PATCH 1/2] [AST] Print the "aggregate" kind for aggregate deduction
 guide decl.

I found this is useful for debugging purpose to identify different kind of 
deduction guide decl.
---
 clang/include/clang/AST/TextNodeDumper.h    |  1 +
 clang/lib/AST/TextNodeDumper.cpp            | 12 ++++++++++++
 clang/test/SemaTemplate/deduction-guide.cpp |  9 +++++++++
 3 files changed, 22 insertions(+)

diff --git a/clang/include/clang/AST/TextNodeDumper.h 
b/clang/include/clang/AST/TextNodeDumper.h
index de67f0b5714846..efb5bfe7f83d40 100644
--- a/clang/include/clang/AST/TextNodeDumper.h
+++ b/clang/include/clang/AST/TextNodeDumper.h
@@ -352,6 +352,7 @@ class TextNodeDumper
   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 b683eb1edd8f13..347a1ede3d1123 100644
--- a/clang/lib/AST/TextNodeDumper.cpp
+++ b/clang/lib/AST/TextNodeDumper.cpp
@@ -1990,6 +1990,18 @@ 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 16c7083df29d0c..0caef78fedbfd9 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

>From 7e6f1759735888dafce2c2b8ddba0b732700e4c8 Mon Sep 17 00:00:00 2001
From: Haojian Wu <hokein...@gmail.com>
Date: Thu, 28 Mar 2024 12:55:38 +0100
Subject: [PATCH 2/2] Fix format.

---
 clang/lib/AST/TextNodeDumper.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/clang/lib/AST/TextNodeDumper.cpp b/clang/lib/AST/TextNodeDumper.cpp
index 347a1ede3d1123..413e452146bdb2 100644
--- a/clang/lib/AST/TextNodeDumper.cpp
+++ b/clang/lib/AST/TextNodeDumper.cpp
@@ -1990,7 +1990,8 @@ void TextNodeDumper::VisitFunctionDecl(const FunctionDecl 
*D) {
   }
 }
 
-void TextNodeDumper::VisitCXXDeductionGuideDecl(const CXXDeductionGuideDecl 
*D) {
+void TextNodeDumper::VisitCXXDeductionGuideDecl(
+    const CXXDeductionGuideDecl *D) {
   VisitFunctionDecl(D);
   switch (D->getDeductionCandidateKind()) {
   case DeductionCandidate::Normal:

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to