Skip to content

[clang] Forward TPL of NestedNameSpecifier #18464

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 6, 2025
Merged
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
17 changes: 10 additions & 7 deletions interpreter/llvm-project/clang/lib/AST/NestedNameSpecifier.cpp
Original file line number Diff line number Diff line change
@@ -285,13 +285,16 @@ void NestedNameSpecifier::print(raw_ostream &OS, const PrintingPolicy &Policy,
case TypeSpec: {
const auto *Record =
dyn_cast_or_null<ClassTemplateSpecializationDecl>(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,16 +318,16 @@ 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<DependentTemplateSpecializationType>(T)) {
// Print the template name without its corresponding
// nested-name-specifier.
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);
2 changes: 1 addition & 1 deletion interpreter/llvm-project/llvm-project.tag
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ROOT-llvm18-20250407-01
ROOT-llvm18-20250506-01
2 changes: 2 additions & 0 deletions roottest/root/meta/naming/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -4,3 +4,5 @@ ROOTTEST_ADD_AUTOMACROS(DEPENDS namingMatches.cxx
ROOTTEST_ADD_TEST(execCheckNaming
MACRO execCheckNaming.C
OUTREF execCheckNaming${ref_suffix})

ROOTTEST_ADD_TESTDIRS()
6 changes: 6 additions & 0 deletions roottest/root/meta/naming/issue-18363/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ROOTTEST_GENERATE_REFLEX_DICTIONARY(templateDict Objects.h SELECTION selection.xml FIXTURES_SETUP template_lib)

ROOTTEST_ADD_TEST(templateName
MACRO templateNameTest.C
OUTREF templateNameTest.ref
FIXTURES_REQUIRED template_lib)
9 changes: 9 additions & 0 deletions roottest/root/meta/naming/issue-18363/Objects.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef Objects_18363_hxx
#define Objects_18363_hxx

template <unsigned I>
struct PFRecHitSoALayout {
struct View {};
};

#endif
4 changes: 4 additions & 0 deletions roottest/root/meta/naming/issue-18363/selection.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<lcgdict>
<class name="PFRecHitSoALayout<128>"/>
<class name="PFRecHitSoALayout<128>::View"/>
</lcgdict>
26 changes: 26 additions & 0 deletions roottest/root/meta/naming/issue-18363/templateNameTest.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
TFile pcmfile("templateDict_rdict.pcm");
if (pcmfile.IsZombie()) {
std::cerr << "Error: Failed to open roottest/root pcm file: " << pcmfile.GetName() << '\n';
return 1;
}
TObjArray *protoArray = pcmfile.Get<TObjArray>("__ProtoClasses");
if (!protoArray) {
std::cerr << "Error: Failed to retrieve __ProtoClasses\n";
return 2;
}
protoArray->Print();

const char *classname = "PFRecHitSoALayout<128>::View";
auto cl = TClass::GetClass(classname);
if (!cl) {
std::cerr << "Error: Could not get the TClass for " << classname << "\n";
return 3;
}
if (!cl->IsLoaded()) {
std::cerr << "Error: The TClass is not loaded for " << classname << "\n";
return 4;
}

return 0;
}
5 changes: 5 additions & 0 deletions roottest/root/meta/naming/issue-18363/templateNameTest.ref
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

Processing templateNameTest.C...
Collection name='TObjArray', class='TObjArray', size=16
OBJ: TProtoClass PFRecHitSoALayout<128>
OBJ: TProtoClass PFRecHitSoALayout<128>::View