diff --git a/include/swift/Frontend/ModuleInterfaceLoader.h b/include/swift/Frontend/ModuleInterfaceLoader.h index 8be00a2ee8e89..04c039be8dabe 100644 --- a/include/swift/Frontend/ModuleInterfaceLoader.h +++ b/include/swift/Frontend/ModuleInterfaceLoader.h @@ -237,6 +237,8 @@ class ExplicitCASModuleLoader : public SerializedModuleLoaderBase { void collectVisibleTopLevelModuleNames( SmallVectorImpl &names) const override; + void addExplicitModulePath(StringRef name, std::string path) override; + ~ExplicitCASModuleLoader(); }; diff --git a/lib/Frontend/ModuleInterfaceLoader.cpp b/lib/Frontend/ModuleInterfaceLoader.cpp index a28673ed23027..4db7520d2ce5a 100644 --- a/lib/Frontend/ModuleInterfaceLoader.cpp +++ b/lib/Frontend/ModuleInterfaceLoader.cpp @@ -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::create( ASTContext &ctx, llvm::cas::ObjectStore &CAS, llvm::cas::ActionCache &cache, DependencyTracker *tracker, ModuleLoadingMode loadMode,