Skip to content

Commit d9c9d5e

Browse files
committed
[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
1 parent bee1ed3 commit d9c9d5e

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
@@ -2791,6 +2791,22 @@ void ExplicitCASModuleLoader::collectVisibleTopLevelModuleNames(
27912791
}
27922792
}
27932793

2794+
void ExplicitCASModuleLoader::addExplicitModulePath(StringRef name,
2795+
std::string path) {
2796+
// This is used by LLDB to discover the paths to dependencies of binary Swift
2797+
// modules. Only do this if path exists in CAS, since there are use-cases
2798+
// where a binary Swift module produced on a different machine is provided and
2799+
// replacements for its dependencies are provided via the explicit module map.
2800+
auto ID = Impl.CAS.parseID(path);
2801+
if (!ID)
2802+
return;
2803+
if (!Impl.CAS.getReference(*ID))
2804+
return;
2805+
2806+
ExplicitSwiftModuleInputInfo entry(path, {}, {}, {});
2807+
Impl.ExplicitModuleMap.try_emplace(name, std::move(entry));
2808+
}
2809+
27942810
std::unique_ptr<ExplicitCASModuleLoader> ExplicitCASModuleLoader::create(
27952811
ASTContext &ctx, llvm::cas::ObjectStore &CAS, llvm::cas::ActionCache &cache,
27962812
DependencyTracker *tracker, ModuleLoadingMode loadMode,

0 commit comments

Comments
 (0)