Skip to content

Commit 5a339b0

Browse files
authored
[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.
1 parent 10516be commit 5a339b0

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

446446
// Use the dependency scanning optimized file system if requested to do so.
447447
if (DepFS) {
448-
SmallString<256> ModulesCachePath;
449-
normalizeModuleCachePath(
450-
*FileMgr, ScanInstance.getHeaderSearchOpts().ModuleCachePath,
451-
ModulesCachePath);
452448
DepFS->resetBypassedPathPrefix();
453-
if (!ModulesCachePath.empty())
449+
if (!ScanInstance.getHeaderSearchOpts().ModuleCachePath.empty()) {
450+
SmallString<256> ModulesCachePath;
451+
normalizeModuleCachePath(
452+
*FileMgr, ScanInstance.getHeaderSearchOpts().ModuleCachePath,
453+
ModulesCachePath);
454454
DepFS->setBypassedPathPrefix(ModulesCachePath);
455+
}
455456

456457
ScanInstance.setDependencyDirectivesGetter(
457458
std::make_unique<ScanningDependencyDirectivesGetter>(*FileMgr));

0 commit comments

Comments
 (0)