Skip to content

Commit 70787ce

Browse files
committed
[cling][FIXME:REWORK] Use AlwaysIncludeTypeForTemplateArgument only for large values
1 parent 28a9ef5 commit 70787ce

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

Diff for: core/clingutils/src/TClingUtils.cxx

-1
Original file line numberDiff line numberDiff line change
@@ -4164,7 +4164,6 @@ void ROOT::TMetaUtils::GetNormalizedName(std::string &norm_name, const clang::Qu
41644164
policy.SuppressTagKeyword = true; // Never get the class or struct keyword
41654165
policy.SuppressScope = true; // Force the scope to be coming from a clang::ElaboratedType.
41664166
policy.AnonymousTagLocations = false; // Do not extract file name + line number for anonymous types.
4167-
policy.AlwaysIncludeTypeForTemplateArgument = true; // Always include type for template arguments
41684167
// The scope suppression is required for getting rid of the anonymous part of the name of a class defined in an anonymous namespace.
41694168
// This gives us more control vs not using the clang::ElaboratedType and relying on the Policy.SuppressUnwrittenScope which would
41704169
// strip both the anonymous and the inline namespace names (and we probably do not want the later to be suppressed).

Diff for: interpreter/cling/lib/Utils/AST.cpp

+12-1
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,18 @@ namespace utils {
265265
ASTContext &mutableCtx( const_cast<ASTContext&>(Ctx) );
266266
arg = TemplateArgument::CreatePackCopy(mutableCtx, desArgs);
267267
}
268+
} else if (arg.getKind() == TemplateArgument::Integral) {
269+
270+
const llvm::APSInt &Val = arg.getAsIntegral();
271+
QualType T = arg.getIntegralType();
272+
273+
// Handle cases where the value is too large to fit into the underlying type
274+
// i.e. where the unsignedness matters.
275+
if (T->isBuiltinType()) {
276+
if (Val.isUnsigned() && Val.getBitWidth() == 64 && Val.countLeadingOnes()) {
277+
const_cast<clang::PrintingPolicy &>(Ctx.getPrintingPolicy()).AlwaysIncludeTypeForTemplateArgument = true;
278+
}
279+
}
268280
}
269281
return changed;
270282
}
@@ -1760,7 +1772,6 @@ namespace utils {
17601772
PrintingPolicy Policy(Ctx.getPrintingPolicy());
17611773
Policy.SuppressScope = false;
17621774
Policy.AnonymousTagLocations = false;
1763-
Policy.AlwaysIncludeTypeForTemplateArgument = true;
17641775
return FQQT.getAsString(Policy);
17651776
}
17661777

0 commit comments

Comments
 (0)