[PATCH] D70236: [AST] Use written names instead of `type-param-0-0` in more cases when printing types and decls.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 14 07:49:00 PST 2019
hokein added inline comments.
================
Comment at: clang/lib/AST/DeclPrinter.cpp:642
DeclPrinter TArgPrinter(POut, SubPolicy, Context, Indentation);
- TArgPrinter.printTemplateArguments(*TArgs);
+ if (const auto *TArgInfo = D->getTemplateSpecializationArgsAsWritten())
+ TArgPrinter.printTemplateArguments(TArgInfo->arguments());
----------------
so here, do we need to respect the `SubPolicy.PrintCanonicalTypes` ?
================
Comment at: clang/lib/AST/DeclPrinter.cpp:1101
Out << ", ";
- if (Params) {
- if (A.getKind() == TemplateArgument::Type)
- if (auto T = A.getAsType()->getAs<TemplateTypeParmType>()) {
- auto P = cast<TemplateTypeParmDecl>(Params->getParam(T->getIndex()));
- Out << *P;
- continue;
- }
- if (A.getKind() == TemplateArgument::Template) {
- if (auto T = A.getAsTemplate().getAsTemplateDecl())
- if (auto TD = dyn_cast<TemplateTemplateParmDecl>(T)) {
- auto P = cast<TemplateTemplateParmDecl>(
- Params->getParam(TD->getIndex()));
- Out << *P;
- continue;
- }
- }
- if (A.getKind() == TemplateArgument::Expression) {
- if (auto E = dyn_cast<DeclRefExpr>(A.getAsExpr()))
- if (auto N = dyn_cast<NonTypeTemplateParmDecl>(E->getDecl())) {
- auto P = cast<NonTypeTemplateParmDecl>(
- Params->getParam(N->getIndex()));
- Out << *P;
- continue;
- }
- }
- }
A.print(Policy, Out);
}
----------------
nit: we can inline A, just `Args[I].print(...)`.
================
Comment at: clang/lib/AST/DeclPrinter.cpp:1112
+ Out << ", ";
+ A.getArgument().print(Policy, Out);
+ }
----------------
the same here.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D70236/new/
https://reviews.llvm.org/D70236
More information about the cfe-commits
mailing list