root icon indicating copy to clipboard operation
root copied to clipboard

`cling::utils::Lookup::Named` does not look into using directive

Open pcanal opened this issue 1 year ago • 0 comments

Check duplicate issues.

  • [ ] Checked for duplicates

Description

This is related to #15406

In a run of cling::utils::Lookup::Named with:

(lldb) p sofar->dumpAsDecl()
NamespaceDecl 0x12e8d0788 </Users/pcanal/root_working/test/2024-meta/test_usingenum.cxx:3:1, col:34> col:11 C
`-UsingDirectiveDecl 0x12e8d0818 <col:15, col:31> col:31 Namespace 0x12e8d0438 'A'

will not look (or at least not find) anything brought by the using directive.

This results in both TClass::GetClass and TClass::GetEnum (even after #15406 is resolved) with nothing find entity that are spelt via a using directive:

This is due to TClassEdit::GetNormalizedName is not correctly resolving the name (due to the incorrect behavior of cling::utils::Lookup::Named

Reproducer

root [0] namespace A { enum E { kOne }; class C; }
root [1] namespace B { using namespace A; }
root [2] TClass::GetClass("A::C")
Warning in <TClass::Init>: no dictionary for class A::C is available
(TClass *) 0x12fe265f0
root [3] TClass::GetClass("B::C")
(TClass *) nullptr
root [4] TEnum::GetEnum("A::E")
(TEnum *) 0x600000e64c30
root [5] TEnum::GetEnum("B::E")
(TEnum *) nullptr
namespace A { enum E { kOne }; class C; }
namespace B { using namespace A; }

int testing()
{
	auto c = TClass::GetClass("B::C");
    if (!c) 
      return 1;
   if (c != TClass::GetClass("A::E");
      return 2;

   // Should work when PR #15408 is merged but does not.
   auto e = TEnum::GetEnum("B::E")
   if (!e)
      return 3;
   if (e != TEnum::GetEnum("A::E");
      return 4;
   return 0;
}

ROOT version

v6.00+ including master

Installation method

any

Operating system

any

Additional context

A commented out part of roottest/root/enums/test_usingenum.cxx is failing due to this issue.

pcanal avatar May 02 '24 21:05 pcanal