Skip to content

Revert "[Dependency Scanning] Use VFS-remapped paths for Clang Module Dependencies' .modulemap files" #70847

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
Jan 11, 2024
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
1 change: 0 additions & 1 deletion include/swift/AST/DiagnosticsSema.def
Original file line number Diff line number Diff line change
Expand Up @@ -2178,7 +2178,6 @@ NOTE(dependency_as_imported_by_main_module,none,
NOTE(dependency_as_imported_by, none,
"a dependency of %select{Swift|Clang}2 module '%0': '%1'", (StringRef, StringRef, bool))
ERROR(clang_dependency_scan_error, none, "Clang dependency scanner failure: %0", (StringRef))
WARNING(clang_dependency_no_modulemap_fileref, none, "Unable to verify Clang dependency module map '%0': $1", (StringRef, StringRef))

// Enum annotations
ERROR(indirect_case_without_payload,none,
Expand Down
30 changes: 6 additions & 24 deletions lib/ClangImporter/ClangModuleDependencyScanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include "clang/Tooling/DependencyScanning/DependencyScanningTool.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Signals.h"
#include "llvm/Support/Path.h"
Expand Down Expand Up @@ -266,34 +265,17 @@ ModuleDependencyVector ClangImporter::bridgeClangModuleDependencies(
swiftArgs.push_back(IncludeTree);
}

// Ensure we get the external path to the modulemap because it is used as an
// explicit input for the resulting compilation task.
auto moduleMapFile =
getClangInstance().getFileManager().getFileRef(
clangModuleDep.ClangModuleMapFile);
StringRef externalModuleMapPath;
if (auto E = moduleMapFile.takeError()) {
ctx.Diags.diagnose(SourceLoc(),
diag::clang_dependency_no_modulemap_fileref,
clangModuleDep.ClangModuleMapFile,
llvm::toString(std::move(E)));
externalModuleMapPath = clangModuleDep.ClangModuleMapFile;
} else
externalModuleMapPath = moduleMapFile.get().getName();

// Module-level dependencies.
llvm::StringSet<> alreadyAddedModules;
auto dependencies = ModuleDependencyInfo::forClangModule(
pcmPath, externalModuleMapPath.str(), clangModuleDep.ID.ContextHash,
swiftArgs, fileDeps, capturedPCMArgs, RootID, IncludeTree,
/*module-cache-key*/ "");
pcmPath, clangModuleDep.ClangModuleMapFile,
clangModuleDep.ID.ContextHash, swiftArgs, fileDeps, capturedPCMArgs,
RootID, IncludeTree, /*module-cache-key*/ "");
for (const auto &moduleName : clangModuleDep.ClangModuleDeps) {
dependencies.addModuleImport(moduleName.ModuleName, &alreadyAddedModules);
// It is safe to assume that all dependencies of a Clang module are Clang
// modules. Doing this allows us to skip "resolving" Clang modules down
// the line.
dependencies.addModuleDependency(
{moduleName.ModuleName, ModuleDependencyKind::Clang});
// It is safe to assume that all dependencies of a Clang module are Clang modules.
// Doing this allows us to skip "resolving" Clang modules down the line.
dependencies.addModuleDependency({moduleName.ModuleName, ModuleDependencyKind::Clang});
}
dependencies.setIsResolved(true);

Expand Down
50 changes: 0 additions & 50 deletions test/ScanDependencies/modulemap_vfs_remap.swift

This file was deleted.