[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
Tue Jan 16 09:56:36 PST 2018


ioeric created this revision.
ioeric added a reviewer: bkramer.
Herald added subscribers: cfe-commits, klimek.

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.


Repository:
  rC Clang

https://reviews.llvm.org/D42111

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


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.
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;


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


More information about the cfe-commits mailing list