Skip to content

Commit 76c7949

Browse files
Merge pull request #86035 from adrian-prantl/166494766
[LLDB|CAS] Implement ExplicitCASModuleLoader::addExplicitModulePath()
2 parents 797476f + a5d15e3 commit 76c7949

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
@@ -2767,6 +2767,22 @@ void ExplicitCASModuleLoader::collectVisibleTopLevelModuleNames(
27672767
}
27682768
}
27692769

2770+
void ExplicitCASModuleLoader::addExplicitModulePath(StringRef name,
2771+
std::string path) {
2772+
// This is used by LLDB to discover the paths to dependencies of binary Swift
2773+
// modules. Only do this if path exists in CAS, since there are use-cases
2774+
// where a binary Swift module produced on a different machine is provided and
2775+
// replacements for its dependencies are provided via the explicit module map.
2776+
auto ID = Impl.CAS.parseID(path);
2777+
if (!ID)
2778+
return llvm::consumeError(ID.takeError());
2779+
if (!Impl.CAS.getReference(*ID))
2780+
return;
2781+
2782+
ExplicitSwiftModuleInputInfo entry(path, {}, {}, {});
2783+
Impl.ExplicitModuleMap.try_emplace(name, std::move(entry));
2784+
}
2785+
27702786
std::unique_ptr<ExplicitCASModuleLoader> ExplicitCASModuleLoader::create(
27712787
ASTContext &ctx, llvm::cas::ObjectStore &CAS, llvm::cas::ActionCache &cache,
27722788
DependencyTracker *tracker, ModuleLoadingMode loadMode,

0 commit comments

Comments
 (0)