Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions core/clingutils/src/TClingUtils.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}

Expand Down Expand Up @@ -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<class _Tp> becomes std::vector<class Tp>.
/// This only affects parameter names, and so describes a compatible API.
Expand Down
2 changes: 2 additions & 0 deletions interpreter/llvm-project/clang/lib/AST/DeclTemplate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading