Skip to content

Commit

Permalink
[Tooling] Add a isSingleProcess() helper to ToolExecutor
Browse files Browse the repository at this point in the history
Summary:
Used in clangd's symbol builder to optimize for the common
shared-memory executor case.

Reviewers: ioeric

Reviewed By: ioeric

Subscribers: kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D51164

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@340599 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
ilya-biryukov committed Aug 24, 2018
1 parent 18c0403 commit 8d110b0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/clang/Tooling/AllTUsExecution.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class AllTUsToolExecutor : public ToolExecutor {

StringRef getExecutorName() const override { return ExecutorName; }

bool isSingleProcess() const override { return true; }

using ToolExecutor::execute;

llvm::Error
Expand Down
7 changes: 7 additions & 0 deletions include/clang/Tooling/Execution.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ class ToolExecutor {
/// Returns the name of a specific executor.
virtual StringRef getExecutorName() const = 0;

/// Should return true iff executor runs all actions in a single process.
/// Clients can use this signal to find out if they can collect results
/// in-memory (e.g. to avoid serialization costs of using ToolResults).
/// The single-process executors can still run multiple threads, but all
/// executions are guaranteed to share the same memory.
virtual bool isSingleProcess() const = 0;

/// Executes each action with a corresponding arguments adjuster.
virtual llvm::Error
execute(llvm::ArrayRef<
Expand Down
2 changes: 2 additions & 0 deletions include/clang/Tooling/StandaloneExecution.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class StandaloneToolExecutor : public ToolExecutor {

StringRef getExecutorName() const override { return ExecutorName; }

bool isSingleProcess() const override { return true; }

using ToolExecutor::execute;

llvm::Error
Expand Down
2 changes: 2 additions & 0 deletions unittests/Tooling/ExecutionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ class TestToolExecutor : public ToolExecutor {

StringRef getExecutorName() const override { return ExecutorName; }

bool isSingleProcess() const override { return true; }

llvm::Error
execute(llvm::ArrayRef<std::pair<std::unique_ptr<FrontendActionFactory>,
ArgumentsAdjuster>>) override {
Expand Down

0 comments on commit 8d110b0

Please sign in to comment.