[clang] [clang][modulemap] Lazily load module maps by header name (PR #181916)
Michael Spencer via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 18 16:10:20 PST 2026
================
@@ -6316,6 +6316,15 @@ llvm::Error ASTReader::ReadSubmoduleBlock(ModuleFile &F,
CurrentModule->ConfigMacrosExhaustive = ConfigMacrosExhaustive;
CurrentModule->ModuleMapIsPrivate = ModuleMapIsPrivate;
CurrentModule->NamedModuleHasInit = NamedModuleHasInit;
+
+ if (!ParentModule && !F.BaseDirectory.empty()) {
+ if (auto Dir = FileMgr.getOptionalDirectoryRef(F.BaseDirectory))
+ CurrentModule->Directory = *Dir;
+ } else if (ParentModule && ParentModule->Directory) {
+ // Submodules inherit the directory from their parent.
+ CurrentModule->Directory = ParentModule->Directory;
+ }
----------------
Bigcheese wrote:
This only causes problems when lazy loading is enabled, otherwise we load PCMs/module maps in a different order that doesn't expose this issue. When loading the module map first it correctly sets the directory.
Maybe this can be reproduced with an explicit build, `-fmodule-file=` and `
#pragma clang __debug module_map`? I'll see if that works.
https://github.com/llvm/llvm-project/pull/181916
More information about the cfe-commits
mailing list