Skip to content

Commit 4467b69

Browse files
committed
[clang] Forward TPL of NestedNameSpecifier
This avoids type suffixes for integer constants when the type can be inferred from the template parameter. Closes #18363 Co-authored-by: Philippe Canal <[email protected]> (cherry picked from commit 982f5d7)
1 parent e020531 commit 4467b69

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -285,13 +285,16 @@ void NestedNameSpecifier::print(raw_ostream &OS, const PrintingPolicy &Policy,
285285
case TypeSpec: {
286286
const auto *Record =
287287
dyn_cast_or_null<ClassTemplateSpecializationDecl>(getAsRecordDecl());
288-
if (ResolveTemplateArguments && Record) {
288+
const TemplateParameterList *TPL = nullptr;
289+
if (Record) {
290+
TPL = Record->getSpecializedTemplate()->getTemplateParameters();
291+
if (ResolveTemplateArguments) {
289292
// Print the type trait with resolved template parameters.
290293
Record->printName(OS, Policy);
291-
printTemplateArgumentList(
292-
OS, Record->getTemplateArgs().asArray(), Policy,
293-
Record->getSpecializedTemplate()->getTemplateParameters());
294+
printTemplateArgumentList(OS, Record->getTemplateArgs().asArray(),
295+
Policy, TPL);
294296
break;
297+
}
295298
}
296299
const Type *T = getAsType();
297300

@@ -315,16 +318,16 @@ void NestedNameSpecifier::print(raw_ostream &OS, const PrintingPolicy &Policy,
315318
TemplateName::Qualified::None);
316319

317320
// Print the template argument list.
318-
printTemplateArgumentList(OS, SpecType->template_arguments(),
319-
InnerPolicy);
321+
printTemplateArgumentList(OS, SpecType->template_arguments(), InnerPolicy,
322+
TPL);
320323
} else if (const auto *DepSpecType =
321324
dyn_cast<DependentTemplateSpecializationType>(T)) {
322325
// Print the template name without its corresponding
323326
// nested-name-specifier.
324327
OS << DepSpecType->getIdentifier()->getName();
325328
// Print the template argument list.
326329
printTemplateArgumentList(OS, DepSpecType->template_arguments(),
327-
InnerPolicy);
330+
InnerPolicy, TPL);
328331
} else {
329332
// Print the type normally
330333
QualType(T, 0).print(OS, InnerPolicy);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ROOT-llvm16-20250207-01
1+
ROOT-llvm16-20250508-01

0 commit comments

Comments
 (0)