[clang] f712c97 - [clang][deps] Store `IgnoreCWD` on `ModuleDeps` (#184921)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 5 19:53:12 PST 2026
Author: Jan Svoboda
Date: 2026-03-05T19:53:08-08:00
New Revision: f712c97e594312b4dca5b90891de76743c0b51e5
URL: https://github.com/llvm/llvm-project/commit/f712c97e594312b4dca5b90891de76743c0b51e5
DIFF: https://github.com/llvm/llvm-project/commit/f712c97e594312b4dca5b90891de76743c0b51e5.diff
LOG: [clang][deps] Store `IgnoreCWD` on `ModuleDeps` (#184921)
This aligns us with downstream, where we need to be able to query
whether a module depends on CWD or not.
Added:
Modified:
clang/include/clang/DependencyScanning/ModuleDepCollector.h
clang/lib/DependencyScanning/ModuleDepCollector.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/DependencyScanning/ModuleDepCollector.h b/clang/include/clang/DependencyScanning/ModuleDepCollector.h
index 6f6a608f65805..52035dde4a757 100644
--- a/clang/include/clang/DependencyScanning/ModuleDepCollector.h
+++ b/clang/include/clang/DependencyScanning/ModuleDepCollector.h
@@ -163,6 +163,9 @@ struct ModuleDeps {
/// for computing this value.
bool IsInStableDirectories;
+ /// Whether current working directory is ignored.
+ bool IgnoreCWD;
+
/// The path to the modulemap file which defines this module.
///
/// This can be used to explicitly build this module. This file will
@@ -382,7 +385,7 @@ class ModuleDepCollector final : public DependencyCollector {
/// Compute the context hash for \p Deps, and create the mapping
/// \c ModuleDepsByID[Deps.ID] = &Deps.
- void associateWithContextHash(const CowCompilerInvocation &CI, bool IgnoreCWD,
+ void associateWithContextHash(const CowCompilerInvocation &CI,
ModuleDeps &Deps);
};
diff --git a/clang/lib/DependencyScanning/ModuleDepCollector.cpp b/clang/lib/DependencyScanning/ModuleDepCollector.cpp
index 0e2e954702743..a20abf3c8171f 100644
--- a/clang/lib/DependencyScanning/ModuleDepCollector.cpp
+++ b/clang/lib/DependencyScanning/ModuleDepCollector.cpp
@@ -481,7 +481,7 @@ static bool isSafeToIgnoreCWD(const CowCompilerInvocation &CI) {
static std::string getModuleContextHash(const ModuleDeps &MD,
const CowCompilerInvocation &CI,
- bool EagerLoadModules, bool IgnoreCWD,
+ bool EagerLoadModules,
llvm::vfs::FileSystem &VFS) {
llvm::HashBuilder<llvm::TruncatedBLAKE3<16>, llvm::endianness::native>
HashBuilder;
@@ -491,7 +491,7 @@ static std::string getModuleContextHash(const ModuleDeps &MD,
HashBuilder.add(getClangFullRepositoryVersion());
HashBuilder.add(serialization::VERSION_MAJOR, serialization::VERSION_MINOR);
llvm::ErrorOr<std::string> CWD = VFS.getCurrentWorkingDirectory();
- if (CWD && !IgnoreCWD)
+ if (CWD && !MD.IgnoreCWD)
HashBuilder.add(*CWD);
// Hash the BuildInvocation without any input files.
@@ -523,10 +523,10 @@ static std::string getModuleContextHash(const ModuleDeps &MD,
}
void ModuleDepCollector::associateWithContextHash(
- const CowCompilerInvocation &CI, bool IgnoreCWD, ModuleDeps &Deps) {
+ const CowCompilerInvocation &CI, ModuleDeps &Deps) {
Deps.ID.ContextHash =
getModuleContextHash(Deps, CI, Service.getOpts().EagerLoadModules,
- IgnoreCWD, ScanInstance.getVirtualFileSystem());
+ ScanInstance.getVirtualFileSystem());
bool Inserted = ModuleDepsByID.insert({Deps.ID, &Deps}).second;
(void)Inserted;
assert(Inserted && "duplicate module mapping");
@@ -797,7 +797,8 @@ ModuleDepCollectorPP::handleTopLevelModule(const Module *M) {
MD.IsInStableDirectories =
areOptionsInStableDir(MDC.StableDirs, CI.getHeaderSearchOpts());
- MDC.associateWithContextHash(CI, IgnoreCWD, MD);
+ MD.IgnoreCWD = IgnoreCWD;
+ MDC.associateWithContextHash(CI, MD);
// Finish the compiler invocation. Requires dependencies and the context hash.
MDC.addOutputPaths(CI, MD);
More information about the cfe-commits
mailing list