diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Tooling/DependencyScanning/DependencyScanningService.cpp | 5 | ||||
-rw-r--r-- | lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp | 4 | ||||
-rw-r--r-- | lib/Tooling/Tooling.cpp | 8 |
3 files changed, 12 insertions, 5 deletions
diff --git a/lib/Tooling/DependencyScanning/DependencyScanningService.cpp b/lib/Tooling/DependencyScanning/DependencyScanningService.cpp index 48aa68218c..6ddce0dcee 100644 --- a/lib/Tooling/DependencyScanning/DependencyScanningService.cpp +++ b/lib/Tooling/DependencyScanning/DependencyScanningService.cpp @@ -12,5 +12,6 @@ using namespace clang; using namespace tooling; using namespace dependencies; -DependencyScanningService::DependencyScanningService(ScanningMode Mode) - : Mode(Mode) {} +DependencyScanningService::DependencyScanningService(ScanningMode Mode, + bool ReuseFileManager) + : Mode(Mode), ReuseFileManager(ReuseFileManager) {} diff --git a/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp b/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp index c80a55645e..2d49e0d794 100644 --- a/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp +++ b/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp @@ -148,6 +148,8 @@ DependencyScanningWorker::DependencyScanningWorker( if (Service.getMode() == ScanningMode::MinimizedSourcePreprocessing) DepFS = new DependencyScanningWorkerFilesystem(Service.getSharedCache(), RealFS); + if (Service.canReuseFileManager()) + Files = new FileManager(FileSystemOptions(), RealFS); } llvm::Expected<std::string> @@ -164,7 +166,7 @@ DependencyScanningWorker::getDependencyFile(const std::string &Input, /// Create the tool that uses the underlying file system to ensure that any /// file system requests that are made by the driver do not go through the /// dependency scanning filesystem. - tooling::ClangTool Tool(CDB, Input, PCHContainerOps, RealFS); + tooling::ClangTool Tool(CDB, Input, PCHContainerOps, RealFS, Files); Tool.clearArgumentsAdjusters(); Tool.setRestoreWorkingDir(false); Tool.setPrintErrorMessage(false); diff --git a/lib/Tooling/Tooling.cpp b/lib/Tooling/Tooling.cpp index 8c0d13d243..472a3ab57c 100644 --- a/lib/Tooling/Tooling.cpp +++ b/lib/Tooling/Tooling.cpp @@ -378,16 +378,20 @@ bool FrontendActionFactory::runInvocation( ClangTool::ClangTool(const CompilationDatabase &Compilations, ArrayRef<std::string> SourcePaths, std::shared_ptr<PCHContainerOperations> PCHContainerOps, - IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS) + IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS, + IntrusiveRefCntPtr<FileManager> Files) : Compilations(Compilations), SourcePaths(SourcePaths), PCHContainerOps(std::move(PCHContainerOps)), OverlayFileSystem(new llvm::vfs::OverlayFileSystem(std::move(BaseFS))), InMemoryFileSystem(new llvm::vfs::InMemoryFileSystem), - Files(new FileManager(FileSystemOptions(), OverlayFileSystem)) { + Files(Files ? Files + : new FileManager(FileSystemOptions(), OverlayFileSystem)) { OverlayFileSystem->pushOverlay(InMemoryFileSystem); appendArgumentsAdjuster(getClangStripOutputAdjuster()); appendArgumentsAdjuster(getClangSyntaxOnlyAdjuster()); appendArgumentsAdjuster(getClangStripDependencyFileAdjuster()); + if (Files) + Files->setVirtualFileSystem(OverlayFileSystem); } ClangTool::~ClangTool() = default; |