From 474257c94d493df3e3c6874a879b9cbf2bdd0bee Mon Sep 17 00:00:00 2001 From: Jonas Hahnfeld Date: Tue, 6 May 2025 21:50:14 +0200 Subject: [PATCH] [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 (cherry picked from commit 982f5d75afb95054a31dcb3f9fd41374efb321bd) --- .../clang/lib/AST/NestedNameSpecifier.cpp | 17 ++++++++++------- interpreter/llvm-project/llvm-project.tag | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/interpreter/llvm-project/clang/lib/AST/NestedNameSpecifier.cpp b/interpreter/llvm-project/clang/lib/AST/NestedNameSpecifier.cpp index 36f2c47b30005..01adf429f2f26 100644 --- a/interpreter/llvm-project/clang/lib/AST/NestedNameSpecifier.cpp +++ b/interpreter/llvm-project/clang/lib/AST/NestedNameSpecifier.cpp @@ -285,13 +285,16 @@ void NestedNameSpecifier::print(raw_ostream &OS, const PrintingPolicy &Policy, case TypeSpec: { const auto *Record = dyn_cast_or_null(getAsRecordDecl()); - if (ResolveTemplateArguments && Record) { + const TemplateParameterList *TPL = nullptr; + if (Record) { + TPL = Record->getSpecializedTemplate()->getTemplateParameters(); + if (ResolveTemplateArguments) { // Print the type trait with resolved template parameters. Record->printName(OS, Policy); - printTemplateArgumentList( - OS, Record->getTemplateArgs().asArray(), Policy, - Record->getSpecializedTemplate()->getTemplateParameters()); + printTemplateArgumentList(OS, Record->getTemplateArgs().asArray(), + Policy, TPL); break; + } } const Type *T = getAsType(); @@ -315,8 +318,8 @@ void NestedNameSpecifier::print(raw_ostream &OS, const PrintingPolicy &Policy, TemplateName::Qualified::None); // Print the template argument list. - printTemplateArgumentList(OS, SpecType->template_arguments(), - InnerPolicy); + printTemplateArgumentList(OS, SpecType->template_arguments(), InnerPolicy, + TPL); } else if (const auto *DepSpecType = dyn_cast(T)) { // Print the template name without its corresponding @@ -324,7 +327,7 @@ void NestedNameSpecifier::print(raw_ostream &OS, const PrintingPolicy &Policy, OS << DepSpecType->getIdentifier()->getName(); // Print the template argument list. printTemplateArgumentList(OS, DepSpecType->template_arguments(), - InnerPolicy); + InnerPolicy, TPL); } else { // Print the type normally QualType(T, 0).print(OS, InnerPolicy); diff --git a/interpreter/llvm-project/llvm-project.tag b/interpreter/llvm-project/llvm-project.tag index fc890829e8503..2c942e8102e9d 100644 --- a/interpreter/llvm-project/llvm-project.tag +++ b/interpreter/llvm-project/llvm-project.tag @@ -1 +1 @@ -ROOT-llvm16-20250207-01 +ROOT-llvm16-20250508-01