[LLDB|CAS] Implement ExplicitCASModuleLoader::addExplicitModulePath()

This virtual function is called when parsing the control block of a Swift module
to add the dependencies to the module loader's explicit Swift module map. For
the compiler this has no practical effect since the explicit Swift module map
should already cover all dependencies. LLDB doesn't have the explicit Swift
module map and depends on this mechanism to discover dependencies.

rdar://166494766
This commit is contained in:
Adrian Prantl
2025-12-14 14:30:52 -08:00
parent bee1ed3046
commit a5d15e3d82
2 changed files with 18 additions and 0 deletions

View File

@@ -2791,6 +2791,22 @@ void ExplicitCASModuleLoader::collectVisibleTopLevelModuleNames(
}
}
void ExplicitCASModuleLoader::addExplicitModulePath(StringRef name,
std::string path) {
// This is used by LLDB to discover the paths to dependencies of binary Swift
// modules. Only do this if path exists in CAS, since there are use-cases
// where a binary Swift module produced on a different machine is provided and
// replacements for its dependencies are provided via the explicit module map.
auto ID = Impl.CAS.parseID(path);
if (!ID)
return llvm::consumeError(ID.takeError());
if (!Impl.CAS.getReference(*ID))
return;
ExplicitSwiftModuleInputInfo entry(path, {}, {}, {});
Impl.ExplicitModuleMap.try_emplace(name, std::move(entry));
}
std::unique_ptr<ExplicitCASModuleLoader> ExplicitCASModuleLoader::create(
ASTContext &ctx, llvm::cas::ObjectStore &CAS, llvm::cas::ActionCache &cache,
DependencyTracker *tracker, ModuleLoadingMode loadMode,