]> granicus.if.org Git - clang/commitdiff
[Tooling] Correct the total number of files being processed when `filter` is provided.
authorHaojian Wu <hokein@google.com>
Mon, 5 Nov 2018 15:08:00 +0000 (15:08 +0000)
committerHaojian Wu <hokein@google.com>
Mon, 5 Nov 2018 15:08:00 +0000 (15:08 +0000)
Reviewers: ioeric

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D54104

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@346135 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Tooling/AllTUsExecution.cpp

index 5da21e03bcd5ddb247ce2d42fac9500c9eb3be7f..0f172b7829635296546a99f89642bc07816cd598 100644 (file)
@@ -96,7 +96,12 @@ llvm::Error AllTUsToolExecutor::execute(
     llvm::errs() << Msg.str() << "\n";
   };
 
-  auto Files = Compilations.getAllFiles();
+  std::vector<std::string> Files;
+  llvm::Regex RegexFilter(Filter);
+  for (const auto& File : Compilations.getAllFiles()) {
+    if (RegexFilter.match(File))
+      Files.push_back(File);
+  }
   // Add a counter to track the progress.
   const std::string TotalNumStr = std::to_string(Files.size());
   unsigned Counter = 0;
@@ -116,10 +121,7 @@ llvm::Error AllTUsToolExecutor::execute(
       llvm::errs() << "Error while getting current working directory: "
                    << EC.message() << "\n";
     }
-    llvm::Regex RegexFilter(Filter);
     for (std::string File : Files) {
-      if (!RegexFilter.match(File))
-        continue;
       Pool.async(
           [&](std::string Path) {
             Log("[" + std::to_string(Count()) + "/" + TotalNumStr +