<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Apologies for the breakage.<div class=""><br class=""></div><div class="">If anyone can provide the full output from the following command on an affected machine, I would be very grateful.</div><div class=""><br class=""></div><div class="">BUILD_DIR=/Users/vsk/src/builds/llvm-project-master-RA/</div><div class="">SRC_DIR=/Users/vsk/src/llvm-project-master</div><div class="">$BUILD_DIR/bin/llvm-cov report -instr-profile $SRC_DIR/llvm/test/tools/llvm-cov/Inputs/sources_specified/main.profdata    -path-equivalence=/tmp,$SRC_DIR/llvm/test/tools/llvm-cov/Inputs -whitelist-filename-regex='.*extra[/\\].*'    $SRC_DIR/llvm/test/tools/llvm-cov/Inputs/sources_specified/main.covmapping    $SRC_DIR/llvm/test/tools/llvm-cov/Inputs/sources_specified/extra $SRC_DIR/llvm/test/tools/llvm-cov/Inputs/sources_specified/abs.h</div><div class=""><div><br class=""></div><div>On my machine, I see the following output:</div><div><br class=""></div><div>```</div><div>$ $BUILD_DIR/bin/llvm-cov report -instr-profile $SRC_DIR/llvm/test/tools/llvm-cov/Inputs/sources_specified/main.profdata    -path-equivalence=/tmp,$SRC_DIR/llvm/test/tools/llvm-cov/Inputs -whitelist-filename-regex='.*extra[/\\].*'    $SRC_DIR/llvm/test/tools/llvm-cov/Inputs/sources_specified/main.covmapping    $SRC_DIR/llvm/test/tools/llvm-cov/Inputs/sources_specified/extra $SRC_DIR/llvm/test/tools/llvm-cov/Inputs/sources_specified/abs.h<br class="">Filename                      Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover<br class="">-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------<br class="">dec.h                               1                 1     0.00%           1                 1     0.00%           3                 3     0.00%<br class="">inc.h                               1                 0   100.00%           1                 0   100.00%           3                 0   100.00%<br class="">-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------<br class="">TOTAL                               2                 1    50.00%           2                 1    50.00%           6                 3    50.00%</div><div>```</div><div><br class=""></div><div>This output is matched by FileCheck:</div><div><br class=""></div><div>REPORT_WHITELIST_DIR_WITH_SOURCES: {{.*}}dec.h{{.*}}<br class="">REPORT_WHITELIST_DIR_WITH_SOURCES: {{.*}}inc.h{{.*}}<br class=""></div><div><br class=""></div><div>The issue appears to be that on affected bots, FileCheck matches the first line ("dec.h") but not the second ("inc.h"). With the full `report` output in hand, we should be able to explain why.</div><div><br class=""></div><div>thanks,</div><div>vedant</div><div><br class=""><blockquote type="cite" class=""><div class="">On Oct 29, 2019, at 10:41 PM, Vlad Tsyrklevich <<a href="mailto:vlad@tsyrklevich.net" class="">vlad@tsyrklevich.net</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">I've reverted this commit as the test appears to fail on sanitizer and non-sanitizer buildbots, e.g. <a href="http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/36140" class="">http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/36140</a></div><br class=""><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Oct 29, 2019 at 6:40 PM Vedant Kumar via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" class="">llvm-commits@lists.llvm.org</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br class="">
Author: Vedant Kumar<br class="">
Date: 2019-10-29T18:26:33-07:00<br class="">
New Revision: bfed824b57d14e2ba98ddbaf1a1410cf04a3e279<br class="">
<br class="">
URL: <a href="https://github.com/llvm/llvm-project/commit/bfed824b57d14e2ba98ddbaf1a1410cf04a3e279" rel="noreferrer" target="_blank" class="">https://github.com/llvm/llvm-project/commit/bfed824b57d14e2ba98ddbaf1a1410cf04a3e279</a><br class="">
DIFF: <a href="https://github.com/llvm/llvm-project/commit/bfed824b57d14e2ba98ddbaf1a1410cf04a3e279.diff" rel="noreferrer" target="_blank" class="">https://github.com/llvm/llvm-project/commit/bfed824b57d14e2ba98ddbaf1a1410cf04a3e279.diff</a><br class="">
<br class="">
LOG: [llvm-cov] Add option to whitelist filenames<br class="">
<br class="">
Add the `-whitelist-filename-regex` option to restrict coverage<br class="">
reporting to file paths that match a whitelist regex.<br class="">
<br class="">
Patch by Michael Daniels!<br class="">
<br class="">
<a href="rdar://56720320" class="">rdar://56720320</a><br class="">
<br class="">
Added: <br class="">
    llvm/test/tools/llvm-cov/whitelist-filename-regex.test<br class="">
<br class="">
Modified: <br class="">
    llvm/docs/CommandGuide/llvm-cov.rst<br class="">
    llvm/tools/llvm-cov/CodeCoverage.cpp<br class="">
    llvm/tools/llvm-cov/CoverageExporter.h<br class="">
    llvm/tools/llvm-cov/CoverageExporterJson.cpp<br class="">
    llvm/tools/llvm-cov/CoverageExporterJson.h<br class="">
    llvm/tools/llvm-cov/CoverageExporterLcov.cpp<br class="">
    llvm/tools/llvm-cov/CoverageExporterLcov.h<br class="">
    llvm/tools/llvm-cov/CoverageFilters.cpp<br class="">
    llvm/tools/llvm-cov/CoverageFilters.h<br class="">
    llvm/tools/llvm-cov/CoverageReport.cpp<br class="">
    llvm/tools/llvm-cov/CoverageReport.h<br class="">
<br class="">
Removed: <br class="">
<br class="">
<br class="">
<br class="">
################################################################################<br class="">
diff  --git a/llvm/docs/CommandGuide/llvm-cov.rst b/llvm/docs/CommandGuide/llvm-cov.rst<br class="">
index 08123e8cb788..9bc9f7edae21 100644<br class="">
--- a/llvm/docs/CommandGuide/llvm-cov.rst<br class="">
+++ b/llvm/docs/CommandGuide/llvm-cov.rst<br class="">
@@ -259,6 +259,10 @@ OPTIONS<br class="">
<br class="">
  Skip source code files with file paths that match the given regular expression.<br class="">
<br class="">
+.. option:: -whitelist-filename-regex=<PATTERN><br class="">
+<br class="">
+ Show code coverage only for files that match the given regular expression.<br class="">
+<br class="">
 .. option:: -format=<FORMAT><br class="">
<br class="">
  Use the specified output format. The supported formats are: "text", "html".<br class="">
<br class="">
diff  --git a/llvm/test/tools/llvm-cov/whitelist-filename-regex.test b/llvm/test/tools/llvm-cov/whitelist-filename-regex.test<br class="">
new file mode 100644<br class="">
index 000000000000..7039fb532f33<br class="">
--- /dev/null<br class="">
+++ b/llvm/test/tools/llvm-cov/whitelist-filename-regex.test<br class="">
@@ -0,0 +1,88 @@<br class="">
+########################<br class="">
+# Test "report" command.<br class="">
+########################<br class="">
+# Only source files<br class="">
+RUN: llvm-cov report -instr-profile %S/Inputs/sources_specified/main.profdata \<br class="">
+RUN:   -path-equivalence=/tmp,%S/Inputs -whitelist-filename-regex='.*\.cc$' \<br class="">
+RUN:   %S/Inputs/sources_specified/main.covmapping \<br class="">
+RUN:   | FileCheck -check-prefix=REPORT_WHITELIST_SOURCE %s<br class="">
+<br class="">
+REPORT_WHITELIST_SOURCE-NOT: {{.*}}dec.h{{.*}}<br class="">
+REPORT_WHITELIST_SOURCE-NOT: {{.*}}inc.h{{.*}}<br class="">
+REPORT_WHITELIST_SOURCE-NOT: {{.*}}abs.h{{.*}}<br class="">
+REPORT_WHITELIST_SOURCE: {{.*}}<a href="http://main.cc" class="">main.cc</a>{{.*}}<br class="">
+REPORT_WHITELIST_SOURCE: {{^}}TOTAL 1{{.*}}100.00%{{$}}<br class="">
+<br class="">
+# Whitelist all files from "extra" directory.<br class="">
+RUN: llvm-cov report -instr-profile %S/Inputs/sources_specified/main.profdata \<br class="">
+RUN:   -path-equivalence=/tmp,%S/Inputs -whitelist-filename-regex='.*extra[/\\].*' \<br class="">
+RUN:   %S/Inputs/sources_specified/main.covmapping \<br class="">
+RUN:   | FileCheck -check-prefix=REPORT_WHITELIST_DIR %s<br class="">
+<br class="">
+REPORT_WHITELIST_DIR: {{.*}}dec.h{{.*}}<br class="">
+REPORT_WHITELIST_DIR: {{.*}}inc.h{{.*}}<br class="">
+REPORT_WHITELIST_DIR-NOT: {{.*}}abs.h{{.*}}<br class="">
+REPORT_WHITELIST_DIR-NOT: {{.*}}<a href="http://main.cc" class="">main.cc</a>{{.*}}<br class="">
+REPORT_WHITELIST_DIR: {{^}}TOTAL 2{{.*}}50.00%{{$}}<br class="">
+<br class="">
+# Whitelist ignored files<br class="">
+RUN: llvm-cov report -instr-profile %S/Inputs/sources_specified/main.profdata \<br class="">
+RUN:   -path-equivalence=/tmp,%S/Inputs \<br class="">
+RUN:   -ignore-filename-regex='.*' -whitelist-filename-regex='.*' \<br class="">
+RUN:   %S/Inputs/sources_specified/main.covmapping \<br class="">
+RUN:   | FileCheck -check-prefix=REPORT_WHITELIST_IGNORED %s<br class="">
+<br class="">
+REPORT_WHITELIST_IGNORED-NOT: {{.*}}dec.h{{.*}}<br class="">
+REPORT_WHITELIST_IGNORED-NOT: {{.*}}inc.h{{.*}}<br class="">
+REPORT_WHITELIST_IGNORED-NOT: {{.*}}abs.h{{.*}}<br class="">
+REPORT_WHITELIST_IGNORED-NOT: {{.*}}<a href="http://main.cc" class="">main.cc</a>{{.*}}<br class="">
+REPORT_WHITELIST_IGNORED-NOT: {{^}}TOTAL 0{{.*}}0.00%{{$}}<br class="">
+<br class="">
+# Whitelist all files from "extra" directory even when SOURCES specified.<br class="">
+RUN: llvm-cov report -instr-profile %S/Inputs/sources_specified/main.profdata \<br class="">
+RUN:   -path-equivalence=/tmp,%S/Inputs -whitelist-filename-regex='.*extra[/\\].*' \<br class="">
+RUN:   %S/Inputs/sources_specified/main.covmapping \<br class="">
+RUN:   %S/Inputs/sources_specified/extra %S/Inputs/sources_specified/abs.h \<br class="">
+RUN:   | FileCheck -check-prefix=REPORT_WHITELIST_DIR_WITH_SOURCES %s<br class="">
+<br class="">
+REPORT_WHITELIST_DIR_WITH_SOURCES: {{.*}}dec.h{{.*}}<br class="">
+REPORT_WHITELIST_DIR_WITH_SOURCES: {{.*}}inc.h{{.*}}<br class="">
+REPORT_WHITELIST_DIR_WITH_SOURCES-NOT: {{.*}}abs.h{{.*}}<br class="">
+REPORT_WHITELIST_DIR_WITH_SOURCES-NOT: {{.*}}<a href="http://main.cc" class="">main.cc</a>{{.*}}<br class="">
+REPORT_WHITELIST_DIR_WITH_SOURCES: {{^}}TOTAL 2{{.*}}50.00%{{$}}<br class="">
+<br class="">
+########################<br class="">
+# Test "show" command.<br class="">
+########################<br class="">
+# Whitelist a couple files<br class="">
+RUN: llvm-cov show -instr-profile %S/Inputs/sources_specified/main.profdata \<br class="">
+RUN:   -path-equivalence=/tmp,%S/Inputs \<br class="">
+RUN:   -whitelist-filename-regex='.*\.cc$' -whitelist-filename-regex='.*abs\.h$' \<br class="">
+RUN:   %S/Inputs/sources_specified/main.covmapping \<br class="">
+RUN:   | FileCheck -check-prefix=SHOW_WHITELIST_CC %s<br class="">
+<br class="">
+# Order of files may <br class="">
diff er, check that there are 3 files and not abs.h.<br class="">
+SHOW_IGNORE_CC-NOT: {{.*}}<a href="http://main.cc" class="">main.cc</a>{{.*}}<br class="">
+<br class="">
+SHOW_WHITELIST_CC-NOT: {{.*}}dec.h{{.*}}<br class="">
+SHOW_WHITELIST_CC-NOT: {{.*}}inc.h{{.*}}<br class="">
+SHOW_WHITELIST_CC: {{.*}}sources_specified{{.*}}<br class="">
+SHOW_WHITELIST_CC: {{.*}}sources_specified{{.*}}<br class="">
+<br class="">
+########################<br class="">
+# Test "export" command.<br class="">
+########################<br class="">
+# Use a temp .json file as output in a single line. Whitelist headers that have<br class="">
+# an 'a' follow by 2 chars followed by '.h'.<br class="">
+RUN: llvm-cov export -instr-profile %S/Inputs/sources_specified/main.profdata \<br class="">
+RUN:   -path-equivalence=/tmp,%S/Inputs -whitelist-filename-regex='.*a..\.h$' \<br class="">
+RUN:   %S/Inputs/sources_specified/main.covmapping \<br class="">
+RUN:   > %t.export.json<br class="">
+<br class="">
+RUN: FileCheck -check-prefix=NO-EXPORT_WHITELIST_3_SYMBOLS_H %s < %t.export.json<br class="">
+RUN: FileCheck -check-prefix=EXPORT_WHITELIST_3_SYMBOLS_H %s < %t.export.json<br class="">
+<br class="">
+NO-EXPORT_WHITELIST_3_SYMBOLS_H-NOT: {{"filename":"(/|\\\\)tmp(/|\\\\)sources_specified(/|\\\\)inc.h"}}<br class="">
+NO-EXPORT_WHITELIST_3_SYMBOLS_H-NOT: {{"filename":"(/|\\\\)tmp(/|\\\\)sources_specified(/|\\\\)dec.h"}}<br class="">
+NO-EXPORT_WHITELIST_3_SYMBOLS_H-NOT: {{"filename":"(/|\\\\)tmp(/|\\\\)sources_specified(/|\\\\)<a href="http://main.cc" class="">main.cc</a>"}}<br class="">
+EXPORT_WHITELIST_3_SYMBOLS_H: {{"filename":"(/|\\\\)tmp(/|\\\\)sources_specified(/|\\\\)abs.h"}}<br class="">
<br class="">
diff  --git a/llvm/tools/llvm-cov/CodeCoverage.cpp b/llvm/tools/llvm-cov/CodeCoverage.cpp<br class="">
index 7151cfb032f3..79c58450f0dd 100644<br class="">
--- a/llvm/tools/llvm-cov/CodeCoverage.cpp<br class="">
+++ b/llvm/tools/llvm-cov/CodeCoverage.cpp<br class="">
@@ -126,7 +126,7 @@ class CodeCoverageTool {<br class="">
   std::vector<StringRef> ObjectFilenames;<br class="">
   CoverageViewOptions ViewOpts;<br class="">
   CoverageFiltersMatchAll Filters;<br class="">
-  CoverageFilters IgnoreFilenameFilters;<br class="">
+  FilenameCoverageFilters FilenameFilters;<br class="">
<br class="">
   /// The path to the indexed profile.<br class="">
   std::string PGOFilename;<br class="">
@@ -190,7 +190,7 @@ void CodeCoverageTool::addCollectedPath(const std::string &Path) {<br class="">
     return;<br class="">
   }<br class="">
   sys::path::remove_dots(EffectivePath, /*remove_dot_dots=*/true);<br class="">
-  if (!IgnoreFilenameFilters.matchesFilename(EffectivePath))<br class="">
+  if (FilenameFilters.matchesFilename(EffectivePath))<br class="">
     SourceFiles.emplace_back(EffectivePath.str());<br class="">
 }<br class="">
<br class="">
@@ -595,6 +595,12 @@ int CodeCoverageTool::run(Command Cmd, int argc, const char **argv) {<br class="">
                "regular expression"),<br class="">
       cl::ZeroOrMore, cl::cat(FilteringCategory));<br class="">
<br class="">
+  cl::list<std::string> WhitelistFilenameRegexFilters(<br class="">
+      "whitelist-filename-regex", cl::Optional,<br class="">
+      cl::desc("Show code coverage only for file paths that match the given "<br class="">
+               "regular expression"),<br class="">
+      cl::ZeroOrMore, cl::cat(FilteringCategory));<br class="">
+<br class="">
   cl::list<std::string> IgnoreFilenameRegexFilters(<br class="">
       "ignore-filename-regex", cl::Optional,<br class="">
       cl::desc("Skip source code files with file paths that match the given "<br class="">
@@ -744,10 +750,11 @@ int CodeCoverageTool::run(Command Cmd, int argc, const char **argv) {<br class="">
       Filters.push_back(std::move(StatFilterer));<br class="">
     }<br class="">
<br class="">
-    // Create the ignore filename filters.<br class="">
+    // Create the filename filters.<br class="">
     for (const auto &RE : IgnoreFilenameRegexFilters)<br class="">
-      IgnoreFilenameFilters.push_back(<br class="">
-          std::make_unique<NameRegexCoverageFilter>(RE));<br class="">
+      FilenameFilters.blacklist(std::make_unique<NameRegexCoverageFilter>(RE));<br class="">
+    for (const auto &RE : WhitelistFilenameRegexFilters)<br class="">
+      FilenameFilters.whitelist(std::make_unique<NameRegexCoverageFilter>(RE));<br class="">
<br class="">
     if (!Arches.empty()) {<br class="">
       for (const std::string &Arch : Arches) {<br class="">
@@ -763,7 +770,7 @@ int CodeCoverageTool::run(Command Cmd, int argc, const char **argv) {<br class="">
       }<br class="">
     }<br class="">
<br class="">
-    // IgnoreFilenameFilters are applied even when InputSourceFiles specified.<br class="">
+    // FilenameFilters are applied even when InputSourceFiles specified.<br class="">
     for (const std::string &File : InputSourceFiles)<br class="">
       collectPaths(File);<br class="">
<br class="">
@@ -884,7 +891,7 @@ int CodeCoverageTool::doShow(int argc, const char **argv,<br class="">
   if (SourceFiles.empty())<br class="">
     // Get the source files from the function coverage mapping.<br class="">
     for (StringRef Filename : Coverage->getUniqueSourceFiles()) {<br class="">
-      if (!IgnoreFilenameFilters.matchesFilename(Filename))<br class="">
+      if (FilenameFilters.matchesFilename(Filename))<br class="">
         SourceFiles.push_back(Filename);<br class="">
     }<br class="">
<br class="">
@@ -988,7 +995,7 @@ int CodeCoverageTool::doReport(int argc, const char **argv,<br class="">
   CoverageReport Report(ViewOpts, *Coverage.get());<br class="">
   if (!ShowFunctionSummaries) {<br class="">
     if (SourceFiles.empty())<br class="">
-      Report.renderFileReports(llvm::outs(), IgnoreFilenameFilters);<br class="">
+      Report.renderFileReports(llvm::outs(), FilenameFilters);<br class="">
     else<br class="">
       Report.renderFileReports(llvm::outs(), SourceFiles);<br class="">
   } else {<br class="">
@@ -1054,7 +1061,7 @@ int CodeCoverageTool::doExport(int argc, const char **argv,<br class="">
   }<br class="">
<br class="">
   if (SourceFiles.empty())<br class="">
-    Exporter->renderRoot(IgnoreFilenameFilters);<br class="">
+    Exporter->renderRoot(FilenameFilters);<br class="">
   else<br class="">
     Exporter->renderRoot(SourceFiles);<br class="">
<br class="">
<br class="">
diff  --git a/llvm/tools/llvm-cov/CoverageExporter.h b/llvm/tools/llvm-cov/CoverageExporter.h<br class="">
index 751e55dc0916..03a7447e934c 100644<br class="">
--- a/llvm/tools/llvm-cov/CoverageExporter.h<br class="">
+++ b/llvm/tools/llvm-cov/CoverageExporter.h<br class="">
@@ -40,7 +40,7 @@ class CoverageExporter {<br class="">
   virtual ~CoverageExporter(){};<br class="">
<br class="">
   /// Render the CoverageMapping object.<br class="">
-  virtual void renderRoot(const CoverageFilters &IgnoreFilters) = 0;<br class="">
+  virtual void renderRoot(const FilenameCoverageFilters &FilenameFilters) = 0;<br class="">
<br class="">
   /// Render the CoverageMapping object for specified source files.<br class="">
   virtual void renderRoot(ArrayRef<std::string> SourceFiles) = 0;<br class="">
<br class="">
diff  --git a/llvm/tools/llvm-cov/CoverageExporterJson.cpp b/llvm/tools/llvm-cov/CoverageExporterJson.cpp<br class="">
index 181d428ed9d8..204571b7ee8f 100644<br class="">
--- a/llvm/tools/llvm-cov/CoverageExporterJson.cpp<br class="">
+++ b/llvm/tools/llvm-cov/CoverageExporterJson.cpp<br class="">
@@ -190,10 +190,11 @@ json::Array renderFunctions(<br class="">
<br class="">
 } // end anonymous namespace<br class="">
<br class="">
-void CoverageExporterJson::renderRoot(const CoverageFilters &IgnoreFilters) {<br class="">
+void CoverageExporterJson::renderRoot(<br class="">
+    const FilenameCoverageFilters &FilenameFilters) {<br class="">
   std::vector<std::string> SourceFiles;<br class="">
   for (StringRef SF : Coverage.getUniqueSourceFiles()) {<br class="">
-    if (!IgnoreFilters.matchesFilename(SF))<br class="">
+    if (FilenameFilters.matchesFilename(SF))<br class="">
       SourceFiles.emplace_back(SF);<br class="">
   }<br class="">
   renderRoot(SourceFiles);<br class="">
<br class="">
diff  --git a/llvm/tools/llvm-cov/CoverageExporterJson.h b/llvm/tools/llvm-cov/CoverageExporterJson.h<br class="">
index c19475005552..c0f4f5b4beb4 100644<br class="">
--- a/llvm/tools/llvm-cov/CoverageExporterJson.h<br class="">
+++ b/llvm/tools/llvm-cov/CoverageExporterJson.h<br class="">
@@ -24,7 +24,7 @@ class CoverageExporterJson : public CoverageExporter {<br class="">
       : CoverageExporter(CoverageMapping, Options, OS) {}<br class="">
<br class="">
   /// Render the CoverageMapping object.<br class="">
-  void renderRoot(const CoverageFilters &IgnoreFilters) override;<br class="">
+  void renderRoot(const FilenameCoverageFilters &FilenameFilters) override;<br class="">
<br class="">
   /// Render the CoverageMapping object for specified source files.<br class="">
   void renderRoot(ArrayRef<std::string> SourceFiles) override;<br class="">
<br class="">
diff  --git a/llvm/tools/llvm-cov/CoverageExporterLcov.cpp b/llvm/tools/llvm-cov/CoverageExporterLcov.cpp<br class="">
index d9b0c3b0d7a8..bc9dce852958 100644<br class="">
--- a/llvm/tools/llvm-cov/CoverageExporterLcov.cpp<br class="">
+++ b/llvm/tools/llvm-cov/CoverageExporterLcov.cpp<br class="">
@@ -106,10 +106,11 @@ void renderFiles(raw_ostream &OS, const coverage::CoverageMapping &Coverage,<br class="">
<br class="">
 } // end anonymous namespace<br class="">
<br class="">
-void CoverageExporterLcov::renderRoot(const CoverageFilters &IgnoreFilters) {<br class="">
+void CoverageExporterLcov::renderRoot(<br class="">
+    const FilenameCoverageFilters &FilenameFilters) {<br class="">
   std::vector<std::string> SourceFiles;<br class="">
   for (StringRef SF : Coverage.getUniqueSourceFiles()) {<br class="">
-    if (!IgnoreFilters.matchesFilename(SF))<br class="">
+    if (FilenameFilters.matchesFilename(SF))<br class="">
       SourceFiles.emplace_back(SF);<br class="">
   }<br class="">
   renderRoot(SourceFiles);<br class="">
<br class="">
diff  --git a/llvm/tools/llvm-cov/CoverageExporterLcov.h b/llvm/tools/llvm-cov/CoverageExporterLcov.h<br class="">
index e8a260bf4937..0ffeb1111b8b 100644<br class="">
--- a/llvm/tools/llvm-cov/CoverageExporterLcov.h<br class="">
+++ b/llvm/tools/llvm-cov/CoverageExporterLcov.h<br class="">
@@ -24,7 +24,7 @@ class CoverageExporterLcov : public CoverageExporter {<br class="">
       : CoverageExporter(CoverageMapping, Options, OS) {}<br class="">
<br class="">
   /// Render the CoverageMapping object.<br class="">
-  void renderRoot(const CoverageFilters &IgnoreFilters) override;<br class="">
+  void renderRoot(const FilenameCoverageFilters &FilenameFilters) override;<br class="">
<br class="">
   /// Render the CoverageMapping object for specified source files.<br class="">
   void renderRoot(ArrayRef<std::string> SourceFiles) override;<br class="">
<br class="">
diff  --git a/llvm/tools/llvm-cov/CoverageFilters.cpp b/llvm/tools/llvm-cov/CoverageFilters.cpp<br class="">
index ca241e386e87..57d8d5e5be28 100644<br class="">
--- a/llvm/tools/llvm-cov/CoverageFilters.cpp<br class="">
+++ b/llvm/tools/llvm-cov/CoverageFilters.cpp<br class="">
@@ -83,3 +83,20 @@ bool CoverageFiltersMatchAll::matches(<br class="">
   }<br class="">
   return true;<br class="">
 }<br class="">
+<br class="">
+bool FilenameCoverageFilters::matchesFilename(StringRef Filename) const {<br class="">
+  if (!Whitelist.empty() && !Whitelist.matchesFilename(Filename)) {<br class="">
+    return false;<br class="">
+  }<br class="">
+  return !Blacklist.matchesFilename(Filename);<br class="">
+}<br class="">
+<br class="">
+void FilenameCoverageFilters::whitelist(<br class="">
+    std::unique_ptr<CoverageFilter> Filter) {<br class="">
+  Whitelist.push_back(std::move(Filter));<br class="">
+}<br class="">
+<br class="">
+void FilenameCoverageFilters::blacklist(<br class="">
+    std::unique_ptr<CoverageFilter> Filter) {<br class="">
+  Blacklist.push_back(std::move(Filter));<br class="">
+}<br class="">
<br class="">
diff  --git a/llvm/tools/llvm-cov/CoverageFilters.h b/llvm/tools/llvm-cov/CoverageFilters.h<br class="">
index ce56e1607111..26f8fcc0a0da 100644<br class="">
--- a/llvm/tools/llvm-cov/CoverageFilters.h<br class="">
+++ b/llvm/tools/llvm-cov/CoverageFilters.h<br class="">
@@ -152,6 +152,22 @@ class CoverageFiltersMatchAll : public CoverageFilters {<br class="">
                const coverage::FunctionRecord &Function) const override;<br class="">
 };<br class="">
<br class="">
+/// A collection of filters.<br class="">
+/// Matches filenames that are whitelisted and not blacklisted.<br class="">
+class FilenameCoverageFilters : public CoverageFilter {<br class="">
+protected:<br class="">
+  CoverageFilters Whitelist;<br class="">
+  CoverageFilters Blacklist;<br class="">
+<br class="">
+public:<br class="">
+<br class="">
+  void whitelist(std::unique_ptr<CoverageFilter> Filter);<br class="">
+  void blacklist(std::unique_ptr<CoverageFilter> Filter);<br class="">
+<br class="">
+  bool matchesFilename(StringRef Filename) const override;<br class="">
+};<br class="">
+<br class="">
+<br class="">
 } // namespace llvm<br class="">
<br class="">
 #endif // LLVM_COV_COVERAGEFILTERS_H<br class="">
<br class="">
diff  --git a/llvm/tools/llvm-cov/CoverageReport.cpp b/llvm/tools/llvm-cov/CoverageReport.cpp<br class="">
index 82259542c597..805e465f99c1 100644<br class="">
--- a/llvm/tools/llvm-cov/CoverageReport.cpp<br class="">
+++ b/llvm/tools/llvm-cov/CoverageReport.cpp<br class="">
@@ -379,11 +379,11 @@ std::vector<FileCoverageSummary> CoverageReport::prepareFileReports(<br class="">
 }<br class="">
<br class="">
 void CoverageReport::renderFileReports(<br class="">
-    raw_ostream &OS, const CoverageFilters &IgnoreFilenameFilters) const {<br class="">
+    raw_ostream &OS, const FilenameCoverageFilters &FilenameFilters) const {<br class="">
   std::vector<std::string> UniqueSourceFiles;<br class="">
   for (StringRef SF : Coverage.getUniqueSourceFiles()) {<br class="">
-    // Apply ignore source files filters.<br class="">
-    if (!IgnoreFilenameFilters.matchesFilename(SF))<br class="">
+    // Apply source files filters.<br class="">
+    if (FilenameFilters.matchesFilename(SF))<br class="">
       UniqueSourceFiles.emplace_back(SF.str());<br class="">
   }<br class="">
   renderFileReports(OS, UniqueSourceFiles);<br class="">
<br class="">
diff  --git a/llvm/tools/llvm-cov/CoverageReport.h b/llvm/tools/llvm-cov/CoverageReport.h<br class="">
index f9a092f510b5..7290586f0a05 100644<br class="">
--- a/llvm/tools/llvm-cov/CoverageReport.h<br class="">
+++ b/llvm/tools/llvm-cov/CoverageReport.h<br class="">
@@ -53,7 +53,7 @@ class CoverageReport {<br class="">
<br class="">
   /// Render file reports for every unique file in the coverage mapping.<br class="">
   void renderFileReports(raw_ostream &OS,<br class="">
-                         const CoverageFilters &IgnoreFilenameFilters) const;<br class="">
+                         const FilenameCoverageFilters &FilenameFilters) const;<br class="">
<br class="">
   /// Render file reports for the files specified in \p Files.<br class="">
   void renderFileReports(raw_ostream &OS, ArrayRef<std::string> Files) const;<br class="">
<br class="">
<br class="">
<br class="">
_______________________________________________<br class="">
llvm-commits mailing list<br class="">
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank" class="">llvm-commits@lists.llvm.org</a><br class="">
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank" class="">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br class="">
</blockquote></div>
</div></blockquote></div><br class=""></div></body></html>