Skip to content

Commit 4db01ae

Browse files
jansvoboda11qiongsiwu
authored andcommitted
[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 d421359 commit 4db01ae

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
@@ -602,13 +602,14 @@ class DependencyScanningAction {
602602

603603
// Use the dependency scanning optimized file system if requested to do so.
604604
if (DepFS) {
605-
SmallString<256> ModulesCachePath;
606-
normalizeModuleCachePath(
607-
*FileMgr, ScanInstance.getHeaderSearchOpts().ModuleCachePath,
608-
ModulesCachePath);
609605
DepFS->resetBypassedPathPrefix();
610-
if (!ModulesCachePath.empty())
606+
if (!ScanInstance.getHeaderSearchOpts().ModuleCachePath.empty()) {
607+
SmallString<256> ModulesCachePath;
608+
normalizeModuleCachePath(
609+
*FileMgr, ScanInstance.getHeaderSearchOpts().ModuleCachePath,
610+
ModulesCachePath);
611611
DepFS->setBypassedPathPrefix(ModulesCachePath);
612+
}
612613

613614
ScanInstance.setDependencyDirectivesGetter(
614615
std::make_unique<ScanningDependencyDirectivesGetter>(*FileMgr));

0 commit comments

Comments
 (0)