[clang] 5a339b0 - [clang] Only set non-empty bypass to scan VFS (#159605)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 18 10:51:25 PDT 2025
Author: Jan Svoboda
Date: 2025-09-18T10:51:21-07:00
New Revision: 5a339b074e625a7e9c92ae98b93a2bb5e1ae9524
URL: https://github.com/llvm/llvm-project/commit/5a339b074e625a7e9c92ae98b93a2bb5e1ae9524
DIFF: https://github.com/llvm/llvm-project/commit/5a339b074e625a7e9c92ae98b93a2bb5e1ae9524.diff
LOG: [clang] Only set non-empty bypass to scan VFS (#159605)
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.
Added:
Modified:
clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
Removed:
################################################################################
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));
More information about the cfe-commits
mailing list