diff --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp --- a/clang/lib/AST/TypePrinter.cpp +++ b/clang/lib/AST/TypePrinter.cpp @@ -80,6 +80,21 @@ } }; + class DefaultTemplateArgsPolicyRAII { + PrintingPolicy &Policy; + bool Old; + + public: + explicit DefaultTemplateArgsPolicyRAII(PrintingPolicy &Policy) + : Policy(Policy), Old(Policy.SuppressDefaultTemplateArgs) { + Policy.SuppressDefaultTemplateArgs = false; + } + + ~DefaultTemplateArgsPolicyRAII() { + Policy.SuppressDefaultTemplateArgs = Old; + } + }; + class ElaboratedTypePolicyRAII { PrintingPolicy &Policy; bool SuppressTagKeyword; @@ -1470,6 +1485,7 @@ IncludeStrongLifetimeRAII Strong(Policy); TemplateDecl *TD = T->getTemplateName().getAsTemplateDecl(); + // FIXME: Null TD never excercised in test suite. if (FullyQualify && TD) { if (!Policy.SuppressScope) AppendScope(TD->getDeclContext(), OS, TD->getDeclName()); @@ -1479,7 +1495,9 @@ T->getTemplateName().print(OS, Policy); } - printTemplateArgumentList(OS, T->template_arguments(), Policy); + DefaultTemplateArgsPolicyRAII TemplateArgs(Policy); + const TemplateParameterList *TPL = TD ? TD->getTemplateParameters() : nullptr; + printTemplateArgumentList(OS, T->template_arguments(), Policy, TPL); spaceBeforePlaceHolder(OS); }