[PATCH] D51298: [Tooling] Allow to filter files used by AllTUsExecutor

Ilya Biryukov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 27 05:17:18 PDT 2018


ilya-biryukov created this revision.
ilya-biryukov added a reviewer: ioeric.

This allows to run clang tools in parallel on a subset of files in the
repository.


Repository:
  rC Clang

https://reviews.llvm.org/D51298

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


Index: lib/Tooling/AllTUsExecution.cpp
===================================================================
--- lib/Tooling/AllTUsExecution.cpp
+++ lib/Tooling/AllTUsExecution.cpp
@@ -55,15 +55,18 @@
 
 AllTUsToolExecutor::AllTUsToolExecutor(
     const CompilationDatabase &Compilations, unsigned ThreadCount,
+    std::vector<std::string> Files,
     std::shared_ptr<PCHContainerOperations> PCHContainerOps)
-    : Compilations(Compilations), Results(new ThreadSafeToolResults),
-      Context(Results.get()), ThreadCount(ThreadCount) {}
+    : Compilations(Compilations), Files(std::move(Files)),
+      Results(new ThreadSafeToolResults), Context(Results.get()),
+      ThreadCount(ThreadCount) {}
 
 AllTUsToolExecutor::AllTUsToolExecutor(
     CommonOptionsParser Options, unsigned ThreadCount,
     std::shared_ptr<PCHContainerOperations> PCHContainerOps)
     : OptionsParser(std::move(Options)),
       Compilations(OptionsParser->getCompilations()),
+      Files(OptionsParser->getSourcePathList()),
       Results(new ThreadSafeToolResults), Context(Results.get()),
       ThreadCount(ThreadCount) {}
 
@@ -90,7 +93,8 @@
     llvm::errs() << Msg.str() << "\n";
   };
 
-  auto Files = Compilations.getAllFiles();
+  std::vector<std::string> Files =
+      !this->Files.empty() ? this->Files : Compilations.getAllFiles();
   // Add a counter to track the progress.
   const std::string TotalNumStr = std::to_string(Files.size());
   unsigned Counter = 0;
Index: include/clang/Tooling/AllTUsExecution.h
===================================================================
--- include/clang/Tooling/AllTUsExecution.h
+++ include/clang/Tooling/AllTUsExecution.h
@@ -30,8 +30,11 @@
   /// Init with \p CompilationDatabase.
   /// This uses \p ThreadCount threads to exececute the actions on all files in
   /// parallel. If \p ThreadCount is 0, this uses `llvm::hardware_concurrency`.
+  /// Only processes files in \p Files. However, if \p Files is empty, will
+  /// process all the files in the compilation database.
   AllTUsToolExecutor(const CompilationDatabase &Compilations,
                      unsigned ThreadCount,
+                     std::vector<std::string> Files = {},
                      std::shared_ptr<PCHContainerOperations> PCHContainerOps =
                          std::make_shared<PCHContainerOperations>());
 
@@ -66,6 +69,9 @@
   // Used to store the parser when the executor is initialized with parser.
   llvm::Optional<CommonOptionsParser> OptionsParser;
   const CompilationDatabase &Compilations;
+  /// A list of files executor should run on. When empty, runs over all the
+  /// files in the compilation database.
+  std::vector<std::string> Files;
   std::unique_ptr<ToolResults> Results;
   ExecutionContext Context;
   llvm::StringMap<std::string> OverlayFiles;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51298.162661.patch
Type: text/x-patch
Size: 2806 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180827/cdbd8fb9/attachment-0001.bin>


More information about the cfe-commits mailing list