Skip to content

Commit ec81882

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 040336f commit ec81882

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
@@ -609,13 +609,14 @@ class DependencyScanningAction : public tooling::ToolAction {
609609

610610
// Use the dependency scanning optimized file system if requested to do so.
611611
if (DepFS) {
612-
SmallString<256> ModulesCachePath;
613-
normalizeModuleCachePath(
614-
*FileMgr, ScanInstance.getHeaderSearchOpts().ModuleCachePath,
615-
ModulesCachePath);
616612
DepFS->resetBypassedPathPrefix();
617-
if (!ModulesCachePath.empty())
613+
if (!ScanInstance.getHeaderSearchOpts().ModuleCachePath.empty()) {
614+
SmallString<256> ModulesCachePath;
615+
normalizeModuleCachePath(
616+
*FileMgr, ScanInstance.getHeaderSearchOpts().ModuleCachePath,
617+
ModulesCachePath);
618618
DepFS->setBypassedPathPrefix(ModulesCachePath);
619+
}
619620

620621
ScanInstance.setDependencyDirectivesGetter(
621622
std::make_unique<ScanningDependencyDirectivesGetter>(*FileMgr));

0 commit comments

Comments
 (0)