[clang] cf4a31f - [clang][deps] Remove '-fmodules-cache-path=' arguments
Jan Svoboda via cfe-commits
cfe-commits at lists.llvm.org
Sat Mar 12 03:04:18 PST 2022
Author: Jan Svoboda
Date: 2022-03-12T11:42:07+01:00
New Revision: cf4a31fc0f9745dabbd7d9cba56a6a9045a026d0
URL: https://github.com/llvm/llvm-project/commit/cf4a31fc0f9745dabbd7d9cba56a6a9045a026d0
DIFF: https://github.com/llvm/llvm-project/commit/cf4a31fc0f9745dabbd7d9cba56a6a9045a026d0.diff
LOG: [clang][deps] Remove '-fmodules-cache-path=' arguments
With explicit modules build, the '-fmodules-cache-path=' argument is unused.
This patch removes the argument to avoid warnings or errors (with '-Werror') stemming from that.
Depends on D118915.
Reviewed By: dexonsmith
Differential Revision: https://reviews.llvm.org/D120474
Added:
Modified:
clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
clang/test/ClangScanDeps/modules-inferred-explicit-build.m
clang/tools/clang-scan-deps/ClangScanDeps.cpp
Removed:
################################################################################
diff --git a/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp b/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
index 06d39c266e80c..55d2c48af41a2 100644
--- a/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
+++ b/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
@@ -31,7 +31,13 @@ FullDependencies::getCommandLineWithoutModulePaths() const {
getAdditionalArgsWithoutModulePaths();
Args.insert(Args.end(), AdditionalArgs.begin(), AdditionalArgs.end());
- // TODO: Filter out implicit modules leftovers (e.g. "-fmodules-cache-path=").
+ // This argument is unused in explicit compiles.
+ llvm::erase_if(Args, [](const std::string &Arg) {
+ return Arg.find("-fmodules-cache-path=") == 0;
+ });
+
+ // TODO: Filter out the remaining implicit modules leftovers
+ // (e.g. "-fmodules-prune-interval=" or "-fmodules-prune-after=").
return Args;
}
diff --git a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
index ed18a111e51f3..4d70b0c80aad2 100644
--- a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -51,6 +51,7 @@ CompilerInvocation ModuleDepCollector::makeInvocationForModuleBuildWithoutPaths(
CI.getLangOpts()->ImplicitModules = false;
CI.getHeaderSearchOpts().ImplicitModuleMaps = false;
+ CI.getHeaderSearchOpts().ModuleCachePath.clear();
// Report the prebuilt modules this module uses.
for (const auto &PrebuiltModule : Deps.PrebuiltModuleDeps)
diff --git a/clang/test/ClangScanDeps/modules-inferred-explicit-build.m b/clang/test/ClangScanDeps/modules-inferred-explicit-build.m
index 09101ff89a5e7..5321a13f21910 100644
--- a/clang/test/ClangScanDeps/modules-inferred-explicit-build.m
+++ b/clang/test/ClangScanDeps/modules-inferred-explicit-build.m
@@ -12,7 +12,7 @@
// RUN: %python %S/../../utils/module-deps-to-rsp.py %t.db --tu-index=0 > %t.tu.rsp
// RUN: %clang @%t.inferred.cc1.rsp -pedantic -Werror
// RUN: %clang @%t.system.cc1.rsp -pedantic -Werror
-// RUN: %clang @%t.tu.rsp -pedantic -Werror -Wno-unused-command-line-argument
+// RUN: %clang @%t.tu.rsp -pedantic -Werror
#include <Inferred/Inferred.h>
#include <System/System.h>
diff --git a/clang/tools/clang-scan-deps/ClangScanDeps.cpp b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
index 8d70808575699..8b6697f020ab3 100644
--- a/clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -374,11 +374,11 @@ class FullDeps {
const ModuleDeps &MD = MDIt->second;
StringRef Filename = llvm::sys::path::filename(MD.ImplicitModulePCMPath);
+ StringRef ModuleCachePath = llvm::sys::path::parent_path(
+ llvm::sys::path::parent_path(MD.ImplicitModulePCMPath));
- SmallString<256> ExplicitPCMPath(
- !ModuleFilesDir.empty()
- ? ModuleFilesDir
- : MD.BuildInvocation.getHeaderSearchOpts().ModuleCachePath);
+ SmallString<256> ExplicitPCMPath(!ModuleFilesDir.empty() ? ModuleFilesDir
+ : ModuleCachePath);
llvm::sys::path::append(ExplicitPCMPath, MD.ID.ContextHash, Filename);
return std::string(ExplicitPCMPath);
}
More information about the cfe-commits
mailing list