diff --git a/core/clingutils/src/TClingUtils.cxx b/core/clingutils/src/TClingUtils.cxx index 59fb2f5137635..36524df62f37d 100644 --- a/core/clingutils/src/TClingUtils.cxx +++ b/core/clingutils/src/TClingUtils.cxx @@ -635,6 +635,8 @@ bool TClingLookupHelper::GetPartiallyDesugaredNameWithScopeHandling(const std::s // TMetaUtils::GetNormalizedName, we just do the 'strip leading std' and fix // white space. clang::PrintingPolicy policy(fInterpreter->getCI()->getASTContext().getPrintingPolicy()); + // For now we do not want the integral type suffixes in the normalized name. + policy.NeverIncludeTypeForTemplateArgument = true; policy.SuppressTagKeyword = true; // Never get the class or struct keyword policy.SuppressScope = true; // Force the scope to be coming from a clang::ElaboratedType. // The scope suppression is required for getting rid of the anonymous part of the name of a class defined in an anonymous namespace. @@ -1411,6 +1413,8 @@ void ROOT::TMetaUtils::GetQualifiedName(std::string &qual_name, const clang::Nam { llvm::raw_string_ostream stream(qual_name); clang::PrintingPolicy policy( cl.getASTContext().getPrintingPolicy() ); + // For now we do not want the integral type suffixes in the normalized name. + policy.NeverIncludeTypeForTemplateArgument = true; policy.SuppressTagKeyword = true; // Never get the class or struct keyword policy.SuppressUnwrittenScope = true; // Don't write the inline or anonymous namespace names. @@ -4161,6 +4165,8 @@ void ROOT::TMetaUtils::GetNormalizedName(std::string &norm_name, const clang::Qu clang::ASTContext &ctxt = interpreter.getCI()->getASTContext(); clang::PrintingPolicy policy(ctxt.getPrintingPolicy()); + // For now we do not want the integral type suffixes in the normalized name. + policy.NeverIncludeTypeForTemplateArgument = true; policy.SuppressTagKeyword = true; // Never get the class or struct keyword policy.SuppressScope = true; // Force the scope to be coming from a clang::ElaboratedType. policy.AnonymousTagLocations = false; // Do not extract file name + line number for anonymous types. diff --git a/interpreter/llvm-project/clang/include/clang/AST/PrettyPrinter.h b/interpreter/llvm-project/clang/include/clang/AST/PrettyPrinter.h index da276e26049b0..fda950b834524 100644 --- a/interpreter/llvm-project/clang/include/clang/AST/PrettyPrinter.h +++ b/interpreter/llvm-project/clang/include/clang/AST/PrettyPrinter.h @@ -76,6 +76,7 @@ struct PrintingPolicy { SuppressImplicitBase(false), FullyQualifiedName(false), PrintCanonicalTypes(false), PrintInjectedClassNameWithArguments(true), UsePreferredNames(true), AlwaysIncludeTypeForTemplateArgument(false), + NeverIncludeTypeForTemplateArgument(false), CleanUglifiedParameters(false), EntireContentsOfLargeArray(true), UseEnumerators(true) {} @@ -326,6 +327,13 @@ struct PrintingPolicy { LLVM_PREFERRED_TYPE(bool) unsigned AlwaysIncludeTypeForTemplateArgument : 1; + /// Whether to never use type suffixes (eg: 1U) on integral non-type template + /// parameters. This is useful to cancel the behavior of + /// TemplateParameterList::shouldIncludeTypeForArgument sometimes request the + /// type suffix even if AlwaysIncludeTypeForTemplateArgument is not true. + LLVM_PREFERRED_TYPE(bool) + unsigned NeverIncludeTypeForTemplateArgument : 1; + /// Whether to strip underscores when printing reserved parameter names. /// e.g. std::vector becomes std::vector. /// This only affects parameter names, and so describes a compatible API. diff --git a/interpreter/llvm-project/clang/lib/AST/DeclTemplate.cpp b/interpreter/llvm-project/clang/lib/AST/DeclTemplate.cpp index 5f8baada8ef80..db027451785d6 100644 --- a/interpreter/llvm-project/clang/lib/AST/DeclTemplate.cpp +++ b/interpreter/llvm-project/clang/lib/AST/DeclTemplate.cpp @@ -240,6 +240,8 @@ bool TemplateParameterList::hasAssociatedConstraints() const { bool TemplateParameterList::shouldIncludeTypeForArgument( const PrintingPolicy &Policy, const TemplateParameterList *TPL, unsigned Idx) { + if (Policy.NeverIncludeTypeForTemplateArgument) + return false; if (!TPL || Idx >= TPL->size() || Policy.AlwaysIncludeTypeForTemplateArgument) return true; const NamedDecl *TemplParam = TPL->getParam(Idx);