summaryrefslogtreecommitdiff
path: root/lib/Tooling
diff options
context:
space:
mode:
authorAlex Lorenz <arphaman@gmail.com>2019-08-29 22:56:38 +0000
committerAlex Lorenz <arphaman@gmail.com>2019-08-29 22:56:38 +0000
commit6dae4ca453a79d710b66138df19b6f8a352450da (patch)
tree636a9bac44d27da96a60a7dfa5a9959d8c0851ec /lib/Tooling
parentbc562eec6767f39fa0ffac8308a9d09ec4df68d5 (diff)
downloadclang-6dae4ca453a79d710b66138df19b6f8a352450da.tar.gz
[clang-scan-deps] reuse the file manager across invocations of
the dependency scanner on a single worker thread This behavior can be controlled using the new `-reuse-filemanager` clang-scan-deps option. By default the file manager is reused. The added test/ClangScanDeps/symlink.cpp is able to pass with the reused filemanager after the related FileEntryRef changes landed earlier. The test test/ClangScanDeps/subframework_header_dir_symlink.m still fails when the file manager is reused (I run the FileCheck with not to make it PASS). I will address this in a follow-up patch that improves the DirectoryEntry name modelling in the FileManager. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@370420 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Tooling')
-rw-r--r--lib/Tooling/DependencyScanning/DependencyScanningService.cpp5
-rw-r--r--lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp4
-rw-r--r--lib/Tooling/Tooling.cpp8
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;