Skip to content

Commit

Permalink
[cxxmodules] Use the global module index only when no rootmap candida…
Browse files Browse the repository at this point in the history
…te is found

In the hybrid mode when we use ROOT with modules and third party software
without modules we have two name resolution systems: the global module index (GMI)
and the rootmaps. In case an identifier is defined in both (eg TMVA::Event and
X::Event), the GMI will take priority and load the TMVA module without later
allowing the system to look for other candidates.

This patch uses the GMI only when no rootmap file has told ROOT that it
provides names for the given namespace.

This fixes #9583
  • Loading branch information
vgvassilev committed Jan 16, 2022
1 parent 628e283 commit b5b4eb4
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions core/metacling/src/TClingCallbacks.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -359,16 +359,22 @@ bool TClingCallbacks::LookupObject(const DeclContext* DC, DeclarationName Name)
if (fIsAutoParsingSuspended || fIsAutoLoadingRecursively)
return false;

if (findInGlobalModuleIndex(Name, /*loadFirstMatchOnly*/ false))
return true;

if (Name.getNameKind() != DeclarationName::Identifier)
return false;

// Get the 'lookup' decl context.
// We need to cast away the constness because we will lookup items of this
// namespace/DeclContext
NamespaceDecl* NSD = dyn_cast<NamespaceDecl>(const_cast<DeclContext*>(DC));

// When GMI is mixed with rootmaps, we might have a name for two different
// entities provided by the two systems. In that case check if the rootmaps
// registered the enclosing namespace as a rootmap name resolution namespace
// and only if that was not the case use the information in the GMI.
if (NSD && !TCling__IsAutoLoadNamespaceCandidate(NSD) &&
findInGlobalModuleIndex(Name, /*loadFirstMatchOnly*/ false))
return true;

if (!NSD)
return false;

Expand Down Expand Up @@ -402,6 +408,7 @@ bool TClingCallbacks::LookupObject(const DeclContext* DC, DeclarationName Name)
lookupResults.size()));
return true;
}

return false;
}

Expand Down

0 comments on commit b5b4eb4

Please sign in to comment.