Skip to content

Commit 0a0e7a9

Browse files
committed
llvm: add Policy::NeverIncludeTypeForTemplateArgument.
This is necessary to allow ROOT normalized names to never have the type suffix added to integral template arguments.
1 parent d1717fa commit 0a0e7a9

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

interpreter/llvm-project/clang/include/clang/AST/PrettyPrinter.h

+8
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ struct PrintingPolicy {
7676
SuppressImplicitBase(false), FullyQualifiedName(false),
7777
PrintCanonicalTypes(false), PrintInjectedClassNameWithArguments(true),
7878
UsePreferredNames(true), AlwaysIncludeTypeForTemplateArgument(false),
79+
NeverIncludeTypeForTemplateArgument(false),
7980
CleanUglifiedParameters(false), EntireContentsOfLargeArray(true),
8081
UseEnumerators(true) {}
8182

@@ -326,6 +327,13 @@ struct PrintingPolicy {
326327
LLVM_PREFERRED_TYPE(bool)
327328
unsigned AlwaysIncludeTypeForTemplateArgument : 1;
328329

330+
/// Whether to never use type suffixes (eg: 1U) on integral non-type template
331+
/// parameters. This is useful to cancel the behavior of
332+
/// TemplateParameterList::shouldIncludeTypeForArgument sometimes request the
333+
/// type suffix even if AlwaysIncludeTypeForTemplateArgument is not true.
334+
LLVM_PREFERRED_TYPE(bool)
335+
unsigned NeverIncludeTypeForTemplateArgument : 1;
336+
329337
/// Whether to strip underscores when printing reserved parameter names.
330338
/// e.g. std::vector<class _Tp> becomes std::vector<class Tp>.
331339
/// This only affects parameter names, and so describes a compatible API.

interpreter/llvm-project/clang/lib/AST/DeclTemplate.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,8 @@ bool TemplateParameterList::hasAssociatedConstraints() const {
240240
bool TemplateParameterList::shouldIncludeTypeForArgument(
241241
const PrintingPolicy &Policy, const TemplateParameterList *TPL,
242242
unsigned Idx) {
243+
if (Policy.NeverIncludeTypeForTemplateArgument)
244+
return false;
243245
if (!TPL || Idx >= TPL->size() || Policy.AlwaysIncludeTypeForTemplateArgument)
244246
return true;
245247
const NamedDecl *TemplParam = TPL->getParam(Idx);

0 commit comments

Comments
 (0)