Skip to content

[Fast Dependency Scanner] Ensure Swift modules don't depend on self. #32083

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/FrontendTool/ScanDependencies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ static std::vector<ModuleDependencyID> resolveDirectDependencies(
for (const auto &clangDep : allClangModules) {
if (auto found = ctx.getModuleDependencies(
clangDep, /*onlyClangModule=*/false, cache, ASTDelegate)) {
if (found->getKind() == ModuleDependenciesKind::Swift)
// ASTContext::getModuleDependencies returns dependencies for a module with a given name.
// This Clang module may have the same name as the Swift module we are resolving, so we
// need to make sure we don't add a dependency from a Swift module to itself.
if (found->getKind() == ModuleDependenciesKind::Swift && clangDep != module.first)
result.push_back({clangDep, found->getKind()});
}
}
Expand Down
5 changes: 2 additions & 3 deletions test/ScanDependencies/module_deps.swift
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,9 @@ import G
// CHECK: "directDependencies"
// CHECK-NEXT: {
// CHECK-NEXT: "clang": "G"
// CHECK-NEXT: },
// CHECK-NEXT: {
// CHECK-NEXT: "swift": "G"
// CHECK-NEXT: }
// CHECK-NEXT: ],
// CHECK-NEXT: "details": {

// CHECK: "contextHash": "{{.*}}",
// CHECK: "commandLine": [
Expand Down