[PATCH] D42111: [Tooling] Don't deduplicate tool results in the All-TUs executor.

Eric Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 17 09:38:47 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rC322691: [Tooling] Don't deduplicate tool results in the All-TUs executor. (authored by ioeric, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D42111?vs=129982&id=130204#toc

Repository:
  rC Clang

https://reviews.llvm.org/D42111

Files:
  include/clang/Tooling/AllTUsExecution.h
  lib/Tooling/AllTUsExecution.cpp


Index: include/clang/Tooling/AllTUsExecution.h
===================================================================
--- include/clang/Tooling/AllTUsExecution.h
+++ include/clang/Tooling/AllTUsExecution.h
@@ -22,7 +22,7 @@
 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;
Index: lib/Tooling/AllTUsExecution.cpp
===================================================================
--- lib/Tooling/AllTUsExecution.cpp
+++ lib/Tooling/AllTUsExecution.cpp
@@ -33,24 +33,20 @@
 public:
   void addResult(StringRef Key, StringRef Value) override {
     std::unique_lock<std::mutex> LockGuard(Mutex);
-    Results[Key] = Value;
+    Results.addResult(Key, Value);
   }
 
   std::vector<std::pair<std::string, std::string>> AllKVResults() override {
-    std::vector<std::pair<std::string, std::string>> KVs;
-    for (const auto &Pair : Results)
-      KVs.emplace_back(Pair.first().str(), Pair.second);
-    return KVs;
+    return Results.AllKVResults();
   }
 
   void forEachResult(llvm::function_ref<void(StringRef Key, StringRef Value)>
                          Callback) override {
-    for (const auto &Pair : Results)
-      Callback(Pair.first(), Pair.second);
+    Results.forEachResult(Callback);
   }
 
 private:
-  llvm::StringMap<std::string> Results;
+  InMemoryToolResults Results;
   std::mutex Mutex;
 };
 
@@ -153,9 +149,8 @@
 };
 
 static ToolExecutorPluginRegistry::Add<AllTUsToolExecutorPlugin>
-    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.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42111.130204.patch
Type: text/x-patch
Size: 2072 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180117/cf3341a7/attachment.bin>


More information about the cfe-commits mailing list