diff --git a/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp b/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp --- a/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp +++ b/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp @@ -192,6 +192,11 @@ ScanInstance.getFrontendOpts().ModulesShareFileManager = false; ScanInstance.setFileManager(FileMgr); + // Support for virtual file system overlays. + FileMgr->setVirtualFileSystem(createVFSFromCompilerInvocation( + ScanInstance.getInvocation(), ScanInstance.getDiagnostics(), + FileMgr->getVirtualFileSystemPtr())); + ScanInstance.createSourceManager(*FileMgr); llvm::StringSet<> PrebuiltModulesInputFiles; @@ -206,12 +211,6 @@ // Use the dependency scanning optimized file system if requested to do so. if (DepFS) { - // Support for virtual file system overlays on top of the caching - // filesystem. - FileMgr->setVirtualFileSystem(createVFSFromCompilerInvocation( - ScanInstance.getInvocation(), ScanInstance.getDiagnostics(), - FileMgr->getVirtualFileSystemPtr())); - llvm::IntrusiveRefCntPtr LocalDepFS = DepFS; ScanInstance.getPreprocessorOpts().DependencyDirectivesForFile = diff --git a/clang/test/ClangScanDeps/vfsoverlay.cpp b/clang/test/ClangScanDeps/vfsoverlay.cpp --- a/clang/test/ClangScanDeps/vfsoverlay.cpp +++ b/clang/test/ClangScanDeps/vfsoverlay.cpp @@ -8,8 +8,8 @@ // RUN: cp %S/Inputs/header.h %t.dir/Inputs/header.h // RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/vfsoverlay_cdb.json > %t.cdb // -// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 | \ -// RUN: FileCheck %s +// RUN: clang-scan-deps -compilation-database %t.cdb -mode preprocess-dependency-directives -j 1 | FileCheck %s +// RUN: clang-scan-deps -compilation-database %t.cdb -mode preprocess -j 1 | FileCheck %s #include "not_real.h"