[core] Fix detection of template instantiation with LLVM 22 #23520
All Vouch review confidence checks passed
Residual risk 0.15 = Change Risk (0.37) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 231 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.326
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #23520"
general
weight: 0.35
vgvassilev
TClingCallbacks::findInGlobalModuleIndex()does not load modules while templates are being instantiated. It detected this by checking whetherSema::InstantiatingSpecializationsis non-empty, but since LLVM 22, function definitions are only registered there in builds with assertions (RecursiveInstGuardinSema::InstantiateFunctionDefinition()is under#ifndef NDEBUG). In release builds, the check therefore no longer detects that a function body is being instantiated, and modules get loaded in the middle of it.This makes the outcome of name lookups depend on the order in which modules happen to be loaded. For example, instantiating
RInterface::Snapshot()from the ROOTDataFrame module performs ADL foroperator==in namespacestd. The ADL lookup passes interesting decls to CodeGen, which completes a redeclaration chain, which asks the GMI and loads another module. Afterwards, walking the redeclarations of the found candidates triggers the same lookup again, which replaces the list of external decls that the ADL loop is still iterating over. The remaining candidates, including thestd::basic_stringoverloads, are silently skipped:Use
Sema::inTemplateInstantiation()instead, which is based on the code synthesis contexts and works regardless of assertions.Closes https://github.com/root-project/root/issues/23495 and https://github.com/root-project/root/issues/23470.
🤖 Done with the help of AI
Since the failure that this commit fixes can only be seen without asserts, here are PR builds without asserts to show it work:
without this commit : https://github.com/root-project/root/pull/23496
with this commit : https://github.com/root-project/root/pull/23518