[6.2 🍒][Dependency Scanning] Consider '-swift-module-file' inputs when looking for dependencies

Previously this flag was only used to pass explicit dependencies to compilation tasks. This change adds support for the dependency scanner to also consider these inputs when resolving dependencies.

Resolves https://github.com/swiftlang/swift-driver/issues/1951
This commit is contained in:
Artem Chikin
2025-07-09 16:58:43 -07:00
parent 61157cdd36
commit 89268e9b4d
15 changed files with 84 additions and 24 deletions

View File

@@ -2251,11 +2251,10 @@ struct ExplicitSwiftModuleLoader::Implementation {
}
void addCommandLineExplicitInputs(
const std::vector<std::pair<std::string, std::string>>
&commandLineExplicitInputs) {
const llvm::StringMap<std::string> &commandLineExplicitInputs) {
for (const auto &moduleInput : commandLineExplicitInputs) {
ExplicitSwiftModuleInputInfo entry(moduleInput.second, {}, {}, {});
ExplicitModuleMap.try_emplace(moduleInput.first, std::move(entry));
ExplicitSwiftModuleInputInfo entry(moduleInput.getValue(), {}, {}, {});
ExplicitModuleMap.try_emplace(moduleInput.getKey(), std::move(entry));
}
}
};
@@ -2427,7 +2426,7 @@ std::unique_ptr<ExplicitSwiftModuleLoader>
ExplicitSwiftModuleLoader::create(ASTContext &ctx,
DependencyTracker *tracker, ModuleLoadingMode loadMode,
StringRef ExplicitSwiftModuleMap,
const std::vector<std::pair<std::string, std::string>> &ExplicitSwiftModuleInputs,
const llvm::StringMap<std::string> &ExplicitSwiftModuleInputs,
bool IgnoreSwiftSourceInfoFile) {
auto result = std::unique_ptr<ExplicitSwiftModuleLoader>(
new ExplicitSwiftModuleLoader(ctx, tracker, loadMode,
@@ -2541,11 +2540,10 @@ struct ExplicitCASModuleLoader::Implementation {
}
void addCommandLineExplicitInputs(
const std::vector<std::pair<std::string, std::string>>
&commandLineExplicitInputs) {
const llvm::StringMap<std::string> &commandLineExplicitInputs) {
for (const auto &moduleInput : commandLineExplicitInputs) {
ExplicitSwiftModuleInputInfo entry(moduleInput.second, {}, {}, {});
ExplicitModuleMap.try_emplace(moduleInput.first, std::move(entry));
ExplicitSwiftModuleInputInfo entry(moduleInput.getValue(), {}, {}, {});
ExplicitModuleMap.try_emplace(moduleInput.getKey(), std::move(entry));
}
}
@@ -2782,8 +2780,7 @@ std::unique_ptr<ExplicitCASModuleLoader> ExplicitCASModuleLoader::create(
ASTContext &ctx, llvm::cas::ObjectStore &CAS, llvm::cas::ActionCache &cache,
DependencyTracker *tracker, ModuleLoadingMode loadMode,
StringRef ExplicitSwiftModuleMap,
const std::vector<std::pair<std::string, std::string>>
&ExplicitSwiftModuleInputs,
const llvm::StringMap<std::string> &ExplicitSwiftModuleInputs,
bool IgnoreSwiftSourceInfoFile) {
auto result =
std::unique_ptr<ExplicitCASModuleLoader>(new ExplicitCASModuleLoader(