[clang] 3d7dcec - [clang][TypePrinter] Test TemplateArgument::IsDefaulted when omitting default arguments
Michael Buch via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 26 18:35:14 PST 2023
Author: Michael Buch
Date: 2023-01-27T02:24:33Z
New Revision: 3d7dcec5db2f86bd8b9142d180716725a8fc0b0f
URL: https://github.com/llvm/llvm-project/commit/3d7dcec5db2f86bd8b9142d180716725a8fc0b0f
DIFF: https://github.com/llvm/llvm-project/commit/3d7dcec5db2f86bd8b9142d180716725a8fc0b0f.diff
LOG: [clang][TypePrinter] Test TemplateArgument::IsDefaulted when omitting default arguments
**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
Differential Revision: https://reviews.llvm.org/D141827
Added:
Modified:
clang/lib/AST/TypePrinter.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp
index b710bab0eb97..ed3837ef01d8 100644
--- a/clang/lib/AST/TypePrinter.cpp
+++ b/clang/lib/AST/TypePrinter.cpp
@@ -2109,14 +2109,10 @@ printTo(raw_ostream &OS, ArrayRef<TA> Args, const PrintingPolicy &Policy,
if (TPL && Policy.SuppressDefaultTemplateArgs &&
!Policy.PrintCanonicalTypes && !Args.empty() && !IsPack &&
Args.size() <= TPL->size()) {
- ASTContext &Ctx = TPL->getParam(0)->getASTContext();
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() && getArgument(Args.back()).getIsDefaulted())
Args = Args.drop_back();
}
More information about the cfe-commits
mailing list