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 @@ -2090,11 +2090,19 @@ llvm::SmallVector OrigArgs; for (const TA &A : Args) OrigArgs.push_back(getArgument(A)); - while (!Args.empty() && - isSubstitutedDefaultArgument(Ctx, getArgument(Args.back()), - TPL->getParam(Args.size() - 1), - OrigArgs, TPL->getDepth())) + while (!Args.empty()) { + const auto &CurrArg = getArgument(Args.back()); + + const bool IsDefaulted = CurrArg.getIsDefaulted() || + isSubstitutedDefaultArgument( + Ctx, CurrArg, TPL->getParam(Args.size() - 1), + OrigArgs, TPL->getDepth()); + + if (!IsDefaulted) + break; + Args = Args.drop_back(); + } } const char *Comma = Policy.MSVCFormatting ? "," : ", ";