[clang] [clang][DependencyScanner] Include the working directory in the context hash (PR #73719)

Juergen Ributzka via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 29 08:46:23 PST 2023


================
@@ -325,6 +326,13 @@ static std::string getModuleContextHash(const ModuleDeps &MD,
   // will be readable.
   HashBuilder.add(getClangFullRepositoryVersion());
   HashBuilder.add(serialization::VERSION_MAJOR, serialization::VERSION_MINOR);
+  if (CI.getFileSystemOpts().WorkingDir.empty()) {
+    llvm::ErrorOr<std::string> CWD = VFS.getCurrentWorkingDirectory();
+    if (CWD)
+      HashBuilder.add(*CWD);
+  }
+  // If any of the above options are set, then there must have been a command
----------------
ributzka wrote:

Sometime options are implicitly set in the driver/toolchain based on other external factors. Wouldn't it be more reliable to always hash the WorkingDir?

https://github.com/llvm/llvm-project/pull/73719


More information about the cfe-commits mailing list