From 8d110b092dfd6c842b5a6a389e28daf500f672ac Mon Sep 17 00:00:00 2001 From: Ilya Biryukov Date: Fri, 24 Aug 2018 09:03:29 +0000 Subject: [PATCH] [Tooling] Add a isSingleProcess() helper to ToolExecutor 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 --- include/clang/Tooling/AllTUsExecution.h | 2 ++ include/clang/Tooling/Execution.h | 7 +++++++ include/clang/Tooling/StandaloneExecution.h | 2 ++ unittests/Tooling/ExecutionTest.cpp | 2 ++ 4 files changed, 13 insertions(+) diff --git a/include/clang/Tooling/AllTUsExecution.h b/include/clang/Tooling/AllTUsExecution.h index f199365dc8..ee3843398e 100644 --- a/include/clang/Tooling/AllTUsExecution.h +++ b/include/clang/Tooling/AllTUsExecution.h @@ -45,6 +45,8 @@ public: StringRef getExecutorName() const override { return ExecutorName; } + bool isSingleProcess() const override { return true; } + using ToolExecutor::execute; llvm::Error diff --git a/include/clang/Tooling/Execution.h b/include/clang/Tooling/Execution.h index 68aef53cb5..7f4b145773 100644 --- a/include/clang/Tooling/Execution.h +++ b/include/clang/Tooling/Execution.h @@ -114,6 +114,13 @@ public: /// 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< diff --git a/include/clang/Tooling/StandaloneExecution.h b/include/clang/Tooling/StandaloneExecution.h index 572330e4cc..d787267b6c 100644 --- a/include/clang/Tooling/StandaloneExecution.h +++ b/include/clang/Tooling/StandaloneExecution.h @@ -52,6 +52,8 @@ public: StringRef getExecutorName() const override { return ExecutorName; } + bool isSingleProcess() const override { return true; } + using ToolExecutor::execute; llvm::Error diff --git a/unittests/Tooling/ExecutionTest.cpp b/unittests/Tooling/ExecutionTest.cpp index 26db8c6d0e..e5dc98d228 100644 --- a/unittests/Tooling/ExecutionTest.cpp +++ b/unittests/Tooling/ExecutionTest.cpp @@ -96,6 +96,8 @@ public: StringRef getExecutorName() const override { return ExecutorName; } + bool isSingleProcess() const override { return true; } + llvm::Error execute(llvm::ArrayRef, ArgumentsAdjuster>>) override { -- 2.40.0