← Back to Pull requests

[core] Fix detection of template instantiation with LLVM 22 #23520

Closed
unknown closed this pull request without merging on Sep 28, 2026 09:09 UTC
View on GitHub
unknown unknown commented on Sep 28, 2026 06:28 UTC
Author

TClingCallbacks::findInGlobalModuleIndex() does not load modules while templates are being instantiated. It detected this by checking whether Sema::InstantiatingSpecializations is non-empty, but since LLVM 22, function definitions are only registered there in builds with assertions (RecursiveInstGuard in Sema::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 for operator== in namespace std. 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 the std::basic_string overloads, are silently skipped:

  error: invalid operands to binary expression ('std::string' (aka
  'basic_string<char>') and 'const char[10]')

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

Diff: 231 lines (+173 / -58) across 2 files Reviewer: vgvassilev Review duration: 160m
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
0.37
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
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
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 37% (MEDIUM) · Higher = larger blast radius
37%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 14.6% · Safe to merge
14.6%