From a3998c587e8e14feb9fb57f6243bf03c4ea9575a Mon Sep 17 00:00:00 2001 From: Eric Liu Date: Wed, 17 Jan 2018 17:37:11 +0000 Subject: [PATCH] [Tooling] Don't deduplicate tool results in the All-TUs executor. Summary: As result deduplication or reduction is not supported in the framework, we should leave the deplication to tools (if needed) until the framework supports it. Reviewers: bkramer Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D42111 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@322691 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Tooling/AllTUsExecution.h | 2 +- lib/Tooling/AllTUsExecution.cpp | 17 ++++++----------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/include/clang/Tooling/AllTUsExecution.h b/include/clang/Tooling/AllTUsExecution.h index 102019577c..0417aea6e5 100644 --- a/include/clang/Tooling/AllTUsExecution.h +++ b/include/clang/Tooling/AllTUsExecution.h @@ -22,7 +22,7 @@ namespace clang { namespace tooling { /// \brief Executes given frontend actions on all files/TUs in the compilation -/// database. The final results will be deduplicated by the result key. +/// database. class AllTUsToolExecutor : public ToolExecutor { public: static const char *ExecutorName; diff --git a/lib/Tooling/AllTUsExecution.cpp b/lib/Tooling/AllTUsExecution.cpp index d35f82f40c..0c0854d0ba 100644 --- a/lib/Tooling/AllTUsExecution.cpp +++ b/lib/Tooling/AllTUsExecution.cpp @@ -33,24 +33,20 @@ class ThreadSafeToolResults : public ToolResults { public: void addResult(StringRef Key, StringRef Value) override { std::unique_lock LockGuard(Mutex); - Results[Key] = Value; + Results.addResult(Key, Value); } std::vector> AllKVResults() override { - std::vector> KVs; - for (const auto &Pair : Results) - KVs.emplace_back(Pair.first().str(), Pair.second); - return KVs; + return Results.AllKVResults(); } void forEachResult(llvm::function_ref Callback) override { - for (const auto &Pair : Results) - Callback(Pair.first(), Pair.second); + Results.forEachResult(Callback); } private: - llvm::StringMap Results; + InMemoryToolResults Results; std::mutex Mutex; }; @@ -153,9 +149,8 @@ public: }; static ToolExecutorPluginRegistry::Add - X("all-TUs", - "Runs FrontendActions on all TUs in the compilation database. " - "Tool results are deduplicated by the result key and stored in memory."); + X("all-TUs", "Runs FrontendActions on all TUs in the compilation database. " + "Tool results are stored in memory."); // This anchor is used to force the linker to link in the generated object file // and thus register the plugin. -- 2.40.0