Skip to content

Commit fb8cccf

Browse files
authored
[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.
1 parent 896037c commit fb8cccf

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

clang/include/clang/AST/TextNodeDumper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ class TextNodeDumper
352352
void VisitEnumConstantDecl(const EnumConstantDecl *D);
353353
void VisitIndirectFieldDecl(const IndirectFieldDecl *D);
354354
void VisitFunctionDecl(const FunctionDecl *D);
355+
void VisitCXXDeductionGuideDecl(const CXXDeductionGuideDecl *D);
355356
void VisitFieldDecl(const FieldDecl *D);
356357
void VisitVarDecl(const VarDecl *D);
357358
void VisitBindingDecl(const BindingDecl *D);

clang/lib/AST/TextNodeDumper.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1990,6 +1990,19 @@ void TextNodeDumper::VisitFunctionDecl(const FunctionDecl *D) {
19901990
}
19911991
}
19921992

1993+
void TextNodeDumper::VisitCXXDeductionGuideDecl(
1994+
const CXXDeductionGuideDecl *D) {
1995+
VisitFunctionDecl(D);
1996+
switch (D->getDeductionCandidateKind()) {
1997+
case DeductionCandidate::Normal:
1998+
case DeductionCandidate::Copy:
1999+
return;
2000+
case DeductionCandidate::Aggregate:
2001+
OS << " aggregate ";
2002+
break;
2003+
}
2004+
}
2005+
19932006
void TextNodeDumper::VisitLifetimeExtendedTemporaryDecl(
19942007
const LifetimeExtendedTemporaryDecl *D) {
19952008
OS << " extended by ";

clang/test/SemaTemplate/deduction-guide.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,3 +239,12 @@ F s(0);
239239
// CHECK: |-InjectedClassNameType {{.*}} 'F<>' dependent
240240
// CHECK: | `-CXXRecord {{.*}} 'F'
241241
// CHECK: `-TemplateTypeParmType {{.*}} 'type-parameter-0-1' dependent depth 0 index 1
242+
243+
template<typename T>
244+
struct G { T t; };
245+
246+
G g = {1};
247+
// CHECK-LABEL: Dumping <deduction guide for G>:
248+
// CHECK: FunctionTemplateDecl
249+
// CHECK: |-CXXDeductionGuideDecl {{.*}} implicit <deduction guide for G> 'auto (T) -> G<T>' aggregate
250+
// CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used <deduction guide for G> 'auto (int) -> G<int>' implicit_instantiation aggregate

0 commit comments

Comments
 (0)