Index: lib/AST/ASTDumper.cpp =================================================================== --- lib/AST/ASTDumper.cpp +++ lib/AST/ASTDumper.cpp @@ -1410,11 +1410,11 @@ if (D->isParameterPack()) OS << " ..."; NodeDumper.dumpName(D); - if (D->hasDefaultArgument()) - dumpTemplateArgument(D->getDefaultArgument()); if (auto *From = D->getDefaultArgStorage().getInheritedFrom()) dumpDeclRef(From, D->defaultArgumentWasInherited() ? "inherited from" : "previous"); + if (D->hasDefaultArgument()) + dumpTemplateArgument(D->getDefaultArgument()); } void ASTDumper::VisitNonTypeTemplateParmDecl(const NonTypeTemplateParmDecl *D) { @@ -1423,11 +1423,11 @@ if (D->isParameterPack()) OS << " ..."; NodeDumper.dumpName(D); - if (D->hasDefaultArgument()) - dumpTemplateArgument(D->getDefaultArgument()); if (auto *From = D->getDefaultArgStorage().getInheritedFrom()) dumpDeclRef(From, D->defaultArgumentWasInherited() ? "inherited from" : "previous"); + if (D->hasDefaultArgument()) + dumpTemplateArgument(D->getDefaultArgument()); } void ASTDumper::VisitTemplateTemplateParmDecl( @@ -1437,11 +1437,11 @@ OS << " ..."; 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"); + if (D->hasDefaultArgument()) + dumpTemplateArgumentLoc(D->getDefaultArgument()); } void ASTDumper::VisitUsingDecl(const UsingDecl *D) { Index: test/AST/ast-dump-decl.cpp =================================================================== --- test/AST/ast-dump-decl.cpp +++ test/AST/ast-dump-decl.cpp @@ -327,21 +327,21 @@ // CHECK: ClassTemplateDecl 0x{{[^ ]*}} prev 0x{{[^ ]*}} {{.*}} TestTemplateDefaultType // CHECK-NEXT: TemplateTypeParmDecl -// CHECK-NEXT: TemplateArgument type 'int' // CHECK-NEXT: inherited from TemplateTypeParm 0x{{[^ ]*}} 'T' +// CHECK-NEXT: TemplateArgument type 'int' // CHECK: ClassTemplateDecl 0x{{[^ ]*}} prev 0x{{[^ ]*}} {{.*}} TestTemplateDefaultNonType // CHECK-NEXT: NonTypeTemplateParmDecl +// CHECK-NEXT: inherited from NonTypeTemplateParm 0x{{[^ ]*}} 'I' 'int' // CHECK-NEXT: TemplateArgument expr // 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: TemplateArgument // PR15220 dump instantiation only once namespace testCanonicalTemplate {