r348797 - Re-order content of template parameter dumps
Stephen Kelly via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 10 13:03:00 PST 2018
Author: steveire
Date: Mon Dec 10 13:03:00 2018
New Revision: 348797
URL: http://llvm.org/viewvc/llvm-project?rev=348797&view=rev
Log:
Re-order content of template parameter dumps
Reviewers: aaron.ballman
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D55393
Modified:
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/test/AST/ast-dump-decl.cpp
Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=348797&r1=348796&r2=348797&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Mon Dec 10 13:03:00 2018
@@ -98,10 +98,14 @@ namespace {
void dumpCXXCtorInitializer(const CXXCtorInitializer *Init);
void dumpTemplateParameters(const TemplateParameterList *TPL);
void dumpTemplateArgumentListInfo(const TemplateArgumentListInfo &TALI);
- void dumpTemplateArgumentLoc(const TemplateArgumentLoc &A);
+ void dumpTemplateArgumentLoc(const TemplateArgumentLoc &A,
+ const Decl *From = nullptr,
+ const char *label = nullptr);
void dumpTemplateArgumentList(const TemplateArgumentList &TAL);
void dumpTemplateArgument(const TemplateArgument &A,
- SourceRange R = SourceRange());
+ SourceRange R = SourceRange(),
+ const Decl *From = nullptr,
+ const char *label = nullptr);
template <typename SpecializationDecl>
void dumpTemplateDeclSpecialization(const SpecializationDecl *D,
bool DumpExplicitInst,
@@ -673,8 +677,9 @@ void ASTDumper::dumpTemplateArgumentList
dumpTemplateArgumentLoc(TALI[i]);
}
-void ASTDumper::dumpTemplateArgumentLoc(const TemplateArgumentLoc &A) {
- dumpTemplateArgument(A.getArgument(), A.getSourceRange());
+void ASTDumper::dumpTemplateArgumentLoc(const TemplateArgumentLoc &A,
+ const Decl *From, const char *label) {
+ dumpTemplateArgument(A.getArgument(), A.getSourceRange(), From, label);
}
void ASTDumper::dumpTemplateArgumentList(const TemplateArgumentList &TAL) {
@@ -682,12 +687,17 @@ void ASTDumper::dumpTemplateArgumentList
dumpTemplateArgument(TAL[i]);
}
-void ASTDumper::dumpTemplateArgument(const TemplateArgument &A, SourceRange R) {
+void ASTDumper::dumpTemplateArgument(const TemplateArgument &A, SourceRange R,
+ const Decl *From, const char *label) {
dumpChild([=] {
OS << "TemplateArgument";
if (R.isValid())
NodeDumper.dumpSourceRange(R);
+ if (From) {
+ dumpDeclRef(From, label);
+ }
+
switch (A.getKind()) {
case TemplateArgument::Null:
OS << " null";
@@ -1380,10 +1390,10 @@ void ASTDumper::VisitTemplateTypeParmDec
OS << " ...";
NodeDumper.dumpName(D);
if (D->hasDefaultArgument())
- dumpTemplateArgument(D->getDefaultArgument());
- if (auto *From = D->getDefaultArgStorage().getInheritedFrom())
- dumpDeclRef(From, D->defaultArgumentWasInherited() ? "inherited from"
- : "previous");
+ dumpTemplateArgument(D->getDefaultArgument(), SourceRange(),
+ D->getDefaultArgStorage().getInheritedFrom(),
+ D->defaultArgumentWasInherited() ? "inherited from"
+ : "previous");
}
void ASTDumper::VisitNonTypeTemplateParmDecl(const NonTypeTemplateParmDecl *D) {
@@ -1393,10 +1403,10 @@ void ASTDumper::VisitNonTypeTemplateParm
OS << " ...";
NodeDumper.dumpName(D);
if (D->hasDefaultArgument())
- dumpTemplateArgument(D->getDefaultArgument());
- if (auto *From = D->getDefaultArgStorage().getInheritedFrom())
- dumpDeclRef(From, D->defaultArgumentWasInherited() ? "inherited from"
- : "previous");
+ dumpTemplateArgument(D->getDefaultArgument(), SourceRange(),
+ D->getDefaultArgStorage().getInheritedFrom(),
+ D->defaultArgumentWasInherited() ? "inherited from"
+ : "previous");
}
void ASTDumper::VisitTemplateTemplateParmDecl(
@@ -1407,10 +1417,9 @@ void ASTDumper::VisitTemplateTemplatePar
NodeDumper.dumpName(D);
dumpTemplateParameters(D->getTemplateParameters());
if (D->hasDefaultArgument())
- dumpTemplateArgumentLoc(D->getDefaultArgument());
- if (auto *From = D->getDefaultArgStorage().getInheritedFrom())
- dumpDeclRef(From, D->defaultArgumentWasInherited() ? "inherited from"
- : "previous");
+ dumpTemplateArgumentLoc(
+ D->getDefaultArgument(), D->getDefaultArgStorage().getInheritedFrom(),
+ D->defaultArgumentWasInherited() ? "inherited from" : "previous");
}
void ASTDumper::VisitUsingDecl(const UsingDecl *D) {
Modified: cfe/trunk/test/AST/ast-dump-decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-decl.cpp?rev=348797&r1=348796&r2=348797&view=diff
==============================================================================
--- cfe/trunk/test/AST/ast-dump-decl.cpp (original)
+++ cfe/trunk/test/AST/ast-dump-decl.cpp Mon Dec 10 13:03:00 2018
@@ -328,20 +328,20 @@ namespace testClassTemplateDecl {
// CHECK: ClassTemplateDecl 0x{{[^ ]*}} prev 0x{{[^ ]*}} {{.*}} TestTemplateDefaultType
// CHECK-NEXT: TemplateTypeParmDecl
// CHECK-NEXT: TemplateArgument type 'int'
-// CHECK-NEXT: inherited from TemplateTypeParm 0x{{[^ ]*}} 'T'
+// CHECK-NEXT: inherited from TemplateTypeParm 0x{{[^ ]*}} 'T'
// CHECK: ClassTemplateDecl 0x{{[^ ]*}} prev 0x{{[^ ]*}} {{.*}} TestTemplateDefaultNonType
// CHECK-NEXT: NonTypeTemplateParmDecl
// CHECK-NEXT: TemplateArgument expr
+// CHECK-NEXT: inherited from NonTypeTemplateParm 0x{{[^ ]*}} 'I' 'int'
// CHECK-NEXT: ConstantExpr
// CHECK-NEXT: IntegerLiteral
-// CHECK-NEXT: inherited from NonTypeTemplateParm 0x{{[^ ]*}} 'I' 'int'
// CHECK: ClassTemplateDecl 0x{{[^ ]*}} prev 0x{{[^ ]*}} {{.*}} TestTemplateTemplateDefaultType
// CHECK-NEXT: TemplateTemplateParmDecl
// CHECK-NEXT: TemplateTypeParmDecl
// CHECK-NEXT: TemplateArgument
-// CHECK-NEXT: inherited from TemplateTemplateParm 0x{{[^ ]*}} 'TT'
+// CHECK-NEXT: inherited from TemplateTemplateParm 0x{{[^ ]*}} 'TT'
// PR15220 dump instantiation only once
namespace testCanonicalTemplate {
More information about the cfe-commits
mailing list