[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
This commit is contained in:
Jan Svoboda 2022-03-12 11:42:04 +01:00
parent 7f6af60746
commit cf4a31fc0f
4 changed files with 13 additions and 6 deletions

View File

@ -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;
}

View File

@ -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)

View File

@ -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>

View File

@ -374,11 +374,11 @@ private:
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);
}