[PATCH] D141827: [WIP][clang][TypePrinter] Test TemplateArgument::IsDefaulted when omitting default arguments
Michael Buch via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 16 01:29:55 PST 2023
Michael137 created this revision.
Michael137 added reviewers: erichkeane, aaron.ballman, dblaikie.
Herald added a project: All.
Michael137 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
**Summary**
This patch allows clients who can't properly construct
a `ClassTemplateDecl` to still benefit from the `clang::TypePrinter`s
ability to skip printing defaulted template arguments. The
clients simply have to call `TemplateArgument::setIsDefaulted`
in advance.
See discussion in https://reviews.llvm.org/D140423
**Testing**
- TODO
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D141827
Files:
clang/lib/AST/TypePrinter.cpp
Index: clang/lib/AST/TypePrinter.cpp
===================================================================
--- clang/lib/AST/TypePrinter.cpp
+++ clang/lib/AST/TypePrinter.cpp
@@ -2090,11 +2090,19 @@
llvm::SmallVector<TemplateArgument, 8> 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 ? "," : ", ";
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141827.489458.patch
Type: text/x-patch
Size: 1071 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230116/ac53340a/attachment.bin>
More information about the cfe-commits
mailing list