Skip to content

Commit 8552bc6

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 (cherry picked from commit a5d15e3)
1 parent c1db023 commit 8552bc6

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
@@ -2807,6 +2807,22 @@ void ExplicitCASModuleLoader::collectVisibleTopLevelModuleNames(
28072807
}
28082808
}
28092809

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

0 commit comments

Comments
 (0)