Skip to content

Commit 245e7fa

Browse files
Merge pull request #86037 from adrian-prantl/166494766-6.3
[LLDB|CAS] Implement ExplicitCASModuleLoader::addExplicitModulePath()
2 parents 1416035 + 8552bc6 commit 245e7fa

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

include/swift/Frontend/ModuleInterfaceLoader.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,8 @@ class ExplicitCASModuleLoader : public SerializedModuleLoaderBase {
237237
void collectVisibleTopLevelModuleNames(
238238
SmallVectorImpl<Identifier> &names) const override;
239239

240+
void addExplicitModulePath(StringRef name, std::string path) override;
241+
240242
~ExplicitCASModuleLoader();
241243
};
242244

lib/Frontend/ModuleInterfaceLoader.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2811,6 +2811,22 @@ void ExplicitCASModuleLoader::collectVisibleTopLevelModuleNames(
28112811
}
28122812
}
28132813

2814+
void ExplicitCASModuleLoader::addExplicitModulePath(StringRef name,
2815+
std::string path) {
2816+
// This is used by LLDB to discover the paths to dependencies of binary Swift
2817+
// modules. Only do this if path exists in CAS, since there are use-cases
2818+
// where a binary Swift module produced on a different machine is provided and
2819+
// replacements for its dependencies are provided via the explicit module map.
2820+
auto ID = Impl.CAS.parseID(path);
2821+
if (!ID)
2822+
return llvm::consumeError(ID.takeError());
2823+
if (!Impl.CAS.getReference(*ID))
2824+
return;
2825+
2826+
ExplicitSwiftModuleInputInfo entry(path, {}, {}, {});
2827+
Impl.ExplicitModuleMap.try_emplace(name, std::move(entry));
2828+
}
2829+
28142830
std::unique_ptr<ExplicitCASModuleLoader> ExplicitCASModuleLoader::create(
28152831
ASTContext &ctx, llvm::cas::ObjectStore &CAS, llvm::cas::ActionCache &cache,
28162832
DependencyTracker *tracker, ModuleLoadingMode loadMode,

0 commit comments

Comments
 (0)