Re-order content of template parameter dumps

Reviewers: aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D55393

llvm-svn: 348797
This commit is contained in:
Stephen Kelly 2018-12-10 21:03:00 +00:00
parent bd72be0b44
commit 43835951f4
2 changed files with 29 additions and 20 deletions

View File

@ -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::dumpTemplateArgumentListInfo(
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(const TemplateArgumentList &TAL) {
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::VisitTemplateTypeParmDecl(const TemplateTypeParmDecl *D) {
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::VisitNonTypeTemplateParmDecl(const NonTypeTemplateParmDecl *D) {
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::VisitTemplateTemplateParmDecl(
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) {

View File

@ -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 {