From 0abc7236d896bee17ae0054d5f6f25a409d95017 Mon Sep 17 00:00:00 2001 From: Devajith Valaparambil Sreeramaswamy Date: Wed, 22 Apr 2026 15:33:34 +0200 Subject: [PATCH] [cling] Desugar UsingType in GetFullyQualifiedType The change in getFullyQualifiedType() in the commit https://github.com/llvm/llvm-project/commit/af27466 added explicit desugaring of UsingType: ``` if (isa(QT.getTypePtr())) { return getFullyQualifiedType(QT.getSingleStepDesugaredType(Ctx), Ctx, WithGlobalNsPrefix); } ``` This has been there since LLVM14 and we could disentagle this from the upgrade to LLVM22. This will cause `SG::sgkey_t` to be resolved to its underlying type `uint32_t` when GetFullTypeName() is called, rather than preserving the typedef alias name as before. --- interpreter/cling/lib/Utils/AST.cpp | 8 ++++++++ roottest/root/meta/naming/execResolveTypedef.cxx | 2 +- roottest/root/meta/naming/execResolveTypedef.ref | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/interpreter/cling/lib/Utils/AST.cpp b/interpreter/cling/lib/Utils/AST.cpp index 4cd16d7ebdc24..15bef584677f0 100644 --- a/interpreter/cling/lib/Utils/AST.cpp +++ b/interpreter/cling/lib/Utils/AST.cpp @@ -1722,6 +1722,14 @@ namespace utils { } QT = etype_input->getNamedType(); } + + // We don't consider the alias introduced by `using a::X` as a new type. + // The qualified name is still a::X. + if (const auto* UT = QT->getAs()) { + QT = Ctx.getQualifiedType(UT->getUnderlyingType(), prefix_qualifiers); + return GetFullyQualifiedType(QT, Ctx); + } + if (prefix == nullptr) { // Create a nested name specifier if needed (i.e. if the decl context // is not the global scope. diff --git a/roottest/root/meta/naming/execResolveTypedef.cxx b/roottest/root/meta/naming/execResolveTypedef.cxx index 772609171ce1d..1c6fc0885be36 100644 --- a/roottest/root/meta/naming/execResolveTypedef.cxx +++ b/roottest/root/meta/naming/execResolveTypedef.cxx @@ -225,7 +225,7 @@ int execResolveTypedef() testing("unsigned int", TClassEdit::ResolveTypedef("SG::sgkey_t")); testing("unsigned int", TClass::GetClass("PackedParameters")->GetDataMember("m_sgkey")->GetTrueTypeName()); - testing("SG::sgkey_t", TClass::GetClass("PackedParameters")->GetDataMember("m_sgkey")->GetFullTypeName()); + testing("uint32_t", TClass::GetClass("PackedParameters")->GetDataMember("m_sgkey")->GetFullTypeName()); testing("RT::EX::ClusterSize", TClassEdit::ResolveTypedef("RT::EX::ClusterSize_t")); return 0; } diff --git a/roottest/root/meta/naming/execResolveTypedef.ref b/roottest/root/meta/naming/execResolveTypedef.ref index f1010a164e983..82bcf1edb400d 100644 --- a/roottest/root/meta/naming/execResolveTypedef.ref +++ b/roottest/root/meta/naming/execResolveTypedef.ref @@ -85,6 +85,6 @@ Test 82 The result is correct: ::SomeTypedefName_tSF Test 83 The result is correct: ::int Test 84 The result is correct: unsigned int Test 85 The result is correct: unsigned int -Test 86 The result is correct: SG::sgkey_t +Test 86 The result is correct: uint32_t Test 87 The result is correct: RT::EX::ClusterSize (int) 0