[llvm-branch-commits] [clang] [clang][HeaderSearch] Introduce API to find a module's module map without loading (PR #235835)

Cyndy Ishida via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Oct 29 18:07:03 PDT 2026


================
@@ -305,18 +305,34 @@ Module *HeaderSearch::lookupModule(StringRef ModuleName,
   if (Module || !AllowSearch || !HSOpts.ImplicitModuleMaps)
     return Module;
 
-  if (!lookupModuleWithPrivateFallbacks(ModuleName, ImportLoc,
-                                        AllowExtraModuleMapSearch))
+  if (!lookupModuleWithPrivateFallbacks(
+          ModuleName, ImportLoc, AllowExtraModuleMapSearch, /*Load=*/true))
     return nullptr;
   return ModMap.findOrLoadModule(ModuleName);
 }
 
+OptionalFileEntryRef
+HeaderSearch::lookupModuleMapFileForModule(StringRef ModuleName) {
+  assert(HSOpts.LazyLoadModuleMaps &&
+         "module map lookup requires lazy loading support");
+  if (!ModMap.isModuleKnown(ModuleName)) {
+    if (!HSOpts.ImplicitModuleMaps)
+      return std::nullopt;
+    // If the module map has not already been parsed, look it up.
+    if (!lookupModuleWithPrivateFallbacks(ModuleName, SourceLocation(),
+                                          /*AllowExtraModuleMapSearch=*/false,
----------------
cyndyishida wrote:

I think this only matters when implicit subdirectory search is enabled. I was initially on the fence about adding more piping to support it, but I suppose it's still better to keep parity. 

https://github.com/llvm/llvm-project/pull/235835


More information about the llvm-branch-commits mailing list