Skip to content

Conversation

@jansvoboda11
Copy link
Contributor

Normalizing an empty modules cache path results in an incorrect non-empty path (the working directory). This PR conditionalizes more code to avoid this. Tested downstream by swift/llvm-project and the DependencyScanningCAPITests.DependencyScanningFSCacheOutOfDate unit test.

Normalizing an empty modules cache path results in an incorrect non-empty path (the working directory). This conditionalizes more code to avoid this. Tested downstream by swift/llvm-project and the `DependencyScanningCAPITests.DependencyScanningFSCacheOutOfDate` unit test.
@llvmbot llvmbot added the clang Clang issues not falling into any other category label Sep 18, 2025
@llvmbot
Copy link
Member

llvmbot commented Sep 18, 2025

@llvm/pr-subscribers-clang

Author: Jan Svoboda (jansvoboda11)

Changes

Normalizing an empty modules cache path results in an incorrect non-empty path (the working directory). This PR conditionalizes more code to avoid this. Tested downstream by swift/llvm-project and the DependencyScanningCAPITests.DependencyScanningFSCacheOutOfDate unit test.


Full diff: https://github.com/llvm/llvm-project/pull/159605.diff

1 Files Affected:

  • (modified) clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp (+6-5)
diff --git a/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp b/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
index 0a12c479bf8e3..16cb56fddc006 100644
--- a/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ b/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -445,13 +445,14 @@ class DependencyScanningAction {
 
     // Use the dependency scanning optimized file system if requested to do so.
     if (DepFS) {
-      SmallString<256> ModulesCachePath;
-      normalizeModuleCachePath(
-          *FileMgr, ScanInstance.getHeaderSearchOpts().ModuleCachePath,
-          ModulesCachePath);
       DepFS->resetBypassedPathPrefix();
-      if (!ModulesCachePath.empty())
+      if (!ScanInstance.getHeaderSearchOpts().ModuleCachePath.empty()) {
+        SmallString<256> ModulesCachePath;
+        normalizeModuleCachePath(
+            *FileMgr, ScanInstance.getHeaderSearchOpts().ModuleCachePath,
+            ModulesCachePath);
         DepFS->setBypassedPathPrefix(ModulesCachePath);
+      }
 
       ScanInstance.setDependencyDirectivesGetter(
           std::make_unique<ScanningDependencyDirectivesGetter>(*FileMgr));

Copy link
Contributor

@qiongsiwu qiongsiwu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks!

@jansvoboda11 jansvoboda11 merged commit 5a339b0 into llvm:main Sep 18, 2025
11 checks passed
@jansvoboda11 jansvoboda11 deleted the scan-bypass-prefix branch September 18, 2025 17:51
qiongsiwu pushed a commit to qiongsiwu/llvm-project that referenced this pull request Oct 14, 2025
Normalizing an empty modules cache path results in an incorrect
non-empty path (the working directory). This PR conditionalizes more
code to avoid this. Tested downstream by swift/llvm-project and the
`DependencyScanningCAPITests.DependencyScanningFSCacheOutOfDate` unit
test.

(cherry picked from commit 5a339b0)
jansvoboda11 added a commit to swiftlang/llvm-project that referenced this pull request Oct 15, 2025
Normalizing an empty modules cache path results in an incorrect
non-empty path (the working directory). This PR conditionalizes more
code to avoid this. Tested downstream by swift/llvm-project and the
`DependencyScanningCAPITests.DependencyScanningFSCacheOutOfDate` unit
test.

(cherry picked from commit 5a339b0)
jansvoboda11 added a commit to swiftlang/llvm-project that referenced this pull request Oct 18, 2025
Normalizing an empty modules cache path results in an incorrect
non-empty path (the working directory). This PR conditionalizes more
code to avoid this. Tested downstream by swift/llvm-project and the
`DependencyScanningCAPITests.DependencyScanningFSCacheOutOfDate` unit
test.

(cherry picked from commit 5a339b0)
jansvoboda11 added a commit to swiftlang/llvm-project that referenced this pull request Oct 23, 2025
Normalizing an empty modules cache path results in an incorrect
non-empty path (the working directory). This PR conditionalizes more
code to avoid this. Tested downstream by swift/llvm-project and the
`DependencyScanningCAPITests.DependencyScanningFSCacheOutOfDate` unit
test.

(cherry picked from commit 5a339b0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants