[PATCH] D54092: [Tooling] Add "-filter" option to AllTUsExecution

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 5 01:47:34 PST 2018


hokein created this revision.
hokein added a reviewer: ioeric.

We can run the tools on a subset files of compilation database.


Repository:
  rC Clang

https://reviews.llvm.org/D54092

Files:
  lib/Tooling/AllTUsExecution.cpp


Index: lib/Tooling/AllTUsExecution.cpp
===================================================================
--- lib/Tooling/AllTUsExecution.cpp
+++ lib/Tooling/AllTUsExecution.cpp
@@ -53,6 +53,11 @@
 
 } // namespace
 
+static llvm::cl::opt<std::string> Filter(
+    "filter",
+    llvm::cl::desc("Only process files that match this filter"),
+    llvm::cl::init(".*"));
+
 AllTUsToolExecutor::AllTUsToolExecutor(
     const CompilationDatabase &Compilations, unsigned ThreadCount,
     std::shared_ptr<PCHContainerOperations> PCHContainerOps)
@@ -110,7 +115,10 @@
       llvm::errs() << "Error while getting current working directory: "
                    << EC.message() << "\n";
     }
+    llvm::Regex RegexFilter(Filter);
     for (std::string File : Files) {
+      if (Filter.getNumOccurrences() != 0 && !RegexFilter.match(File))
+        continue;
       Pool.async(
           [&](std::string Path) {
             Log("[" + std::to_string(Count()) + "/" + TotalNumStr +


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54092.172552.patch
Type: text/x-patch
Size: 979 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181105/ad401d4d/attachment.bin>


More information about the cfe-commits mailing list