Skip to content

Commit 7fd9a10

Browse files
committed
[clang] Only set non-empty bypass to scan VFS (llvm#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. (cherry picked from commit 5a339b0)
1 parent 55d8786 commit 7fd9a10

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -606,13 +606,14 @@ class DependencyScanningAction {
606606

607607
// Use the dependency scanning optimized file system if requested to do so.
608608
if (DepFS) {
609-
SmallString<256> ModulesCachePath;
610-
normalizeModuleCachePath(
611-
*FileMgr, ScanInstance.getHeaderSearchOpts().ModuleCachePath,
612-
ModulesCachePath);
613609
DepFS->resetBypassedPathPrefix();
614-
if (!ModulesCachePath.empty())
610+
if (!ScanInstance.getHeaderSearchOpts().ModuleCachePath.empty()) {
611+
SmallString<256> ModulesCachePath;
612+
normalizeModuleCachePath(
613+
*FileMgr, ScanInstance.getHeaderSearchOpts().ModuleCachePath,
614+
ModulesCachePath);
615615
DepFS->setBypassedPathPrefix(ModulesCachePath);
616+
}
616617

617618
ScanInstance.setDependencyDirectivesGetter(
618619
std::make_unique<ScanningDependencyDirectivesGetter>(*FileMgr));

0 commit comments

Comments
 (0)