Skip to content

Commit

Permalink
Follow-up to D77598: Simplify API by passing template parameters only…
Browse files Browse the repository at this point in the history
… when used/to imply "TemplOverloaded/overloadable"

These arguments were redundant, and other parts of D77598 did rely on
the presence/absence of template parameters to imply whether types
should be included for the argument (like
clang::printTemplateArgumentList) so do that here too.
  • Loading branch information
dwblaikie committed Nov 14, 2021
1 parent c3a772f commit 5de3690
Showing 1 changed file with 9 additions and 19 deletions.
28 changes: 9 additions & 19 deletions clang/lib/AST/DeclPrinter.cpp
Expand Up @@ -112,11 +112,9 @@ namespace {
void printTemplateParameters(const TemplateParameterList *Params,
bool OmitTemplateKW = false);
void printTemplateArguments(llvm::ArrayRef<TemplateArgument> Args,
const TemplateParameterList *Params,
bool TemplOverloaded);
const TemplateParameterList *Params);
void printTemplateArguments(llvm::ArrayRef<TemplateArgumentLoc> Args,
const TemplateParameterList *Params,
bool TemplOverloaded);
const TemplateParameterList *Params);
void prettyPrintAttributes(Decl *D);
void prettyPrintPragmas(Decl *D);
void printDeclType(QualType T, StringRef DeclName, bool Pack = false);
Expand Down Expand Up @@ -652,16 +650,11 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
llvm::raw_string_ostream POut(Proto);
DeclPrinter TArgPrinter(POut, SubPolicy, Context, Indentation);
const auto *TArgAsWritten = D->getTemplateSpecializationArgsAsWritten();
const TemplateParameterList *TPL = D->getTemplateSpecializationInfo()
->getTemplate()
->getTemplateParameters();
if (TArgAsWritten && !Policy.PrintCanonicalTypes)
TArgPrinter.printTemplateArguments(TArgAsWritten->arguments(), TPL,
/*TemplOverloaded*/ true);
TArgPrinter.printTemplateArguments(TArgAsWritten->arguments(), nullptr);
else if (const TemplateArgumentList *TArgs =
D->getTemplateSpecializationArgs())
TArgPrinter.printTemplateArguments(TArgs->asArray(), TPL,
/*TemplOverloaded*/ true);
TArgPrinter.printTemplateArguments(TArgs->asArray(), nullptr);
}

QualType Ty = D->getType();
Expand Down Expand Up @@ -1002,8 +995,7 @@ void DeclPrinter::VisitCXXRecordDecl(CXXRecordDecl *D) {
dyn_cast<TemplateSpecializationType>(TSI->getType()))
Args = TST->template_arguments();
printTemplateArguments(
Args, S->getSpecializedTemplate()->getTemplateParameters(),
/*TemplOverloaded*/ false);
Args, S->getSpecializedTemplate()->getTemplateParameters());
}
}

Expand Down Expand Up @@ -1096,13 +1088,12 @@ void DeclPrinter::printTemplateParameters(const TemplateParameterList *Params,
}

void DeclPrinter::printTemplateArguments(ArrayRef<TemplateArgument> Args,
const TemplateParameterList *Params,
bool TemplOverloaded) {
const TemplateParameterList *Params) {
Out << "<";
for (size_t I = 0, E = Args.size(); I < E; ++I) {
if (I)
Out << ", ";
if (TemplOverloaded || !Params)
if (!Params)
Args[I].print(Policy, Out, /*IncludeType*/ true);
else
Args[I].print(Policy, Out,
Expand All @@ -1113,13 +1104,12 @@ void DeclPrinter::printTemplateArguments(ArrayRef<TemplateArgument> Args,
}

void DeclPrinter::printTemplateArguments(ArrayRef<TemplateArgumentLoc> Args,
const TemplateParameterList *Params,
bool TemplOverloaded) {
const TemplateParameterList *Params) {
Out << "<";
for (size_t I = 0, E = Args.size(); I < E; ++I) {
if (I)
Out << ", ";
if (TemplOverloaded)
if (!Params)
Args[I].getArgument().print(Policy, Out, /*IncludeType*/ true);
else
Args[I].getArgument().print(
Expand Down

0 comments on commit 5de3690

Please sign in to comment.