[PATCH] D89359: [llvm-cov] don't include all source files when provided source files are filtered out

Zequan Wu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 13 18:55:13 PDT 2020


zequanwu created this revision.
zequanwu added a reviewer: vsk.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
zequanwu requested review of this revision.

When all provided source files are filtered out either due to `--ignore-filename-regex` or not part of binary, don't generate coverage reults for all source files. Because if users want to generate coverage results for all source files, they don't even need to provid selected source files or `--ignore-filename-regex`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89359

Files:
  llvm/tools/llvm-cov/CodeCoverage.cpp


Index: llvm/tools/llvm-cov/CodeCoverage.cpp
===================================================================
--- llvm/tools/llvm-cov/CodeCoverage.cpp
+++ llvm/tools/llvm-cov/CodeCoverage.cpp
@@ -130,6 +130,9 @@
   CoverageFiltersMatchAll Filters;
   CoverageFilters IgnoreFilenameFilters;
 
+  /// True if InputSourceFiles are provided.
+  bool HasInputSourceFiles;
+
   /// The path to the indexed profile.
   std::string PGOFilename;
 
@@ -777,6 +780,8 @@
       }
     }
 
+    HasInputSourceFiles = !InputSourceFiles.empty();
+
     // IgnoreFilenameFilters are applied even when InputSourceFiles specified.
     for (const std::string &File : InputSourceFiles)
       collectPaths(File);
@@ -895,7 +900,7 @@
 
   auto Printer = CoveragePrinter::create(ViewOpts);
 
-  if (SourceFiles.empty())
+  if (SourceFiles.empty() && !HasInputSourceFiles)
     // Get the source files from the function coverage mapping.
     for (StringRef Filename : Coverage->getUniqueSourceFiles()) {
       if (!IgnoreFilenameFilters.matchesFilename(Filename))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89359.298011.patch
Type: text/x-patch
Size: 1046 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201014/5d8913cc/attachment.bin>


More information about the llvm-commits mailing list