[clang] [clang][Modules] Keep current-TU global-module-fragment internal-linkage functions viable in overload resolution (PR #210825)
David Brittain via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 20 20:52:28 PDT 2026
================
@@ -7388,7 +7388,24 @@ void Sema::AddOverloadCandidate(
Function->isFromGlobalModule() &&
(IsImplicitlyInstantiated || Function->isInlined());
- if (ND->getFormalLinkage() == Linkage::Internal && !IsInlineFunctionInGMF) {
+ /// An internal-linkage function declared in the global module fragment of
+ /// the module unit currently being compiled is usable here
+ /// ([module.global.frag]p1), even a plain 'static' (non-inline) helper.
+ /// Such a helper is dropped here only because
+ /// Function->isInAnotherModuleUnit() misclassifies it when the enclosing
+ /// template is instantiated after the GMF is closed: that check consults
+ /// ASTContext's current *named* module, which is not in scope yet while the
+ /// GMF's pending instantiations run. Comparing against the current module
+ /// scope instead recognises it as belonging to this unit. Only genuinely
+ /// cross-unit uses stay subject to the internal-linkage rule.
----------------
combinatorial wrote:
The comment has been shortened to a single sentence.
https://github.com/llvm/llvm-project/pull/210825
More information about the cfe-commits
mailing list