[llvm] r314782 - [llvm-cov] Hide files with no coverage from the index when filtering by name

Sean Eveson via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 3 04:05:28 PDT 2017


Author: seaneveson
Date: Tue Oct  3 04:05:28 2017
New Revision: 314782

URL: http://llvm.org/viewvc/llvm-project?rev=314782&view=rev
Log:
[llvm-cov] Hide files with no coverage from the index when filtering by name

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

Modified:
    llvm/trunk/test/tools/llvm-cov/dir-with-filtering.test
    llvm/trunk/tools/llvm-cov/CoverageReport.cpp
    llvm/trunk/tools/llvm-cov/CoverageReport.h
    llvm/trunk/tools/llvm-cov/SourceCoverageView.h
    llvm/trunk/tools/llvm-cov/SourceCoverageViewHTML.cpp
    llvm/trunk/tools/llvm-cov/SourceCoverageViewHTML.h
    llvm/trunk/tools/llvm-cov/SourceCoverageViewText.cpp
    llvm/trunk/tools/llvm-cov/SourceCoverageViewText.h

Modified: llvm/trunk/test/tools/llvm-cov/dir-with-filtering.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-cov/dir-with-filtering.test?rev=314782&r1=314781&r2=314782&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-cov/dir-with-filtering.test (original)
+++ llvm/trunk/test/tools/llvm-cov/dir-with-filtering.test Tue Oct  3 04:05:28 2017
@@ -32,6 +32,14 @@ TEXT-INDEX-ONE-FILE-NOT: dir-with-filter
 
 RUN: FileCheck -input-file=%t.text_one_file/coverage/tmp/dir-with-filtering1.cpp.txt %s -check-prefix=TEXT-FILE1
 
+// Test TEXT index file with all functions in one file filtered out
+
+RUN: llvm-cov show %S/Inputs/dir-with-filtering.covmapping -o %t.text_one_func -instr-profile %t.profdata -path-equivalence=/tmp,%S/Inputs -name=main
+RUN: FileCheck -input-file=%t.text_one_func/index.txt %s -check-prefix=TEXT-INDEX-ONE-FUNC
+
+TEXT-INDEX-ONE-FUNC-NOT: Files which contain no functions
+TEXT-INDEX-ONE-FUNC-NOT: dir-with-filtering2.cpp
+
 // Test HTML both files
 
 RUN: llvm-profdata merge %S/Inputs/dir-with-filtering.proftext -o %t.profdata
@@ -67,3 +75,11 @@ HTML-INDEX-ONE-FILE: dir-with-filtering1
 HTML-INDEX-ONE-FILE-NOT: dir-with-filtering2.cpp
 
 RUN: FileCheck -input-file=%t.html_one_file/coverage/tmp/dir-with-filtering1.cpp.html %s -check-prefix=HTML-FILE1
+
+// Test HTML index file with all functions in one file filtered out
+
+RUN: llvm-cov show %S/Inputs/dir-with-filtering.covmapping -format html -o %t.html_one_func -instr-profile %t.profdata -path-equivalence=/tmp,%S/Inputs -name=main
+RUN: FileCheck -input-file=%t.html_one_func/index.html %s -check-prefix=HTML-INDEX-ONE-FUNC
+
+HTML-INDEX-ONE-FUNC-NOT: Files which contain no functions
+HTML-INDEX-ONE-FUNC-NOT: dir-with-filtering2.cpp

Modified: llvm/trunk/tools/llvm-cov/CoverageReport.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/CoverageReport.cpp?rev=314782&r1=314781&r2=314782&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/CoverageReport.cpp (original)
+++ llvm/trunk/tools/llvm-cov/CoverageReport.cpp Tue Oct  3 04:05:28 2017
@@ -367,9 +367,9 @@ void CoverageReport::renderFileReports(r
   renderFileReports(OS, UniqueSourceFiles, CoverageFiltersMatchAll());
 }
 
-void CoverageReport::renderFileReports(raw_ostream &OS,
-                                       ArrayRef<std::string> Files,
-                                       const CoverageFilter &Filters) const {
+void CoverageReport::renderFileReports(
+    raw_ostream &OS, ArrayRef<std::string> Files,
+    const CoverageFiltersMatchAll &Filters) const {
   FileCoverageSummary Totals("TOTAL");
   auto FileReports =
       prepareFileReports(Coverage, Totals, Files, Options, Filters);
@@ -405,7 +405,7 @@ void CoverageReport::renderFileReports(r
       EmptyFiles = true;
   }
 
-  if (EmptyFiles) {
+  if (EmptyFiles && Filters.empty()) {
     OS << "\n"
        << "Files which contain no functions:\n";
 

Modified: llvm/trunk/tools/llvm-cov/CoverageReport.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/CoverageReport.h?rev=314782&r1=314781&r2=314782&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/CoverageReport.h (original)
+++ llvm/trunk/tools/llvm-cov/CoverageReport.h Tue Oct  3 04:05:28 2017
@@ -50,7 +50,7 @@ public:
   /// Render file reports for the files specified in \p Files and the functions
   /// in \p Filters.
   void renderFileReports(raw_ostream &OS, ArrayRef<std::string> Files,
-                         const CoverageFilter &Filters) const;
+                         const CoverageFiltersMatchAll &Filters) const;
 };
 
 } // end namespace llvm

Modified: llvm/trunk/tools/llvm-cov/SourceCoverageView.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/SourceCoverageView.h?rev=314782&r1=314781&r2=314782&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/SourceCoverageView.h (original)
+++ llvm/trunk/tools/llvm-cov/SourceCoverageView.h Tue Oct  3 04:05:28 2017
@@ -22,7 +22,7 @@
 
 namespace llvm {
 
-class CoverageFilter;
+class CoverageFiltersMatchAll;
 class SourceCoverageView;
 
 /// \brief A view that represents a macro or include expansion.
@@ -113,7 +113,7 @@ public:
   /// \brief Create an index which lists reports for the given source files.
   virtual Error createIndexFile(ArrayRef<std::string> SourceFiles,
                                 const coverage::CoverageMapping &Coverage,
-                                const CoverageFilter &Filters) = 0;
+                                const CoverageFiltersMatchAll &Filters) = 0;
 
   /// @}
 };

Modified: llvm/trunk/tools/llvm-cov/SourceCoverageViewHTML.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/SourceCoverageViewHTML.cpp?rev=314782&r1=314781&r2=314782&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/SourceCoverageViewHTML.cpp (original)
+++ llvm/trunk/tools/llvm-cov/SourceCoverageViewHTML.cpp Tue Oct  3 04:05:28 2017
@@ -366,7 +366,8 @@ void CoveragePrinterHTML::emitFileSummar
 
 Error CoveragePrinterHTML::createIndexFile(
     ArrayRef<std::string> SourceFiles,
-    const coverage::CoverageMapping &Coverage, const CoverageFilter &Filters) {
+    const coverage::CoverageMapping &Coverage,
+    const CoverageFiltersMatchAll &Filters) {
   // Emit the default stylesheet.
   auto CSSOrErr = createOutputStream("style", "css", /*InToplevel=*/true);
   if (Error E = CSSOrErr.takeError())
@@ -419,7 +420,7 @@ Error CoveragePrinterHTML::createIndexFi
   // Emit links to files which don't contain any functions. These are normally
   // not very useful, but could be relevant for code which abuses the
   // preprocessor.
-  if (EmptyFiles) {
+  if (EmptyFiles && Filters.empty()) {
     OSRef << tag("p", "Files which contain no functions. (These "
                       "files contain code pulled into other files "
                       "by the preprocessor.)\n");

Modified: llvm/trunk/tools/llvm-cov/SourceCoverageViewHTML.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/SourceCoverageViewHTML.h?rev=314782&r1=314781&r2=314782&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/SourceCoverageViewHTML.h (original)
+++ llvm/trunk/tools/llvm-cov/SourceCoverageViewHTML.h Tue Oct  3 04:05:28 2017
@@ -30,7 +30,7 @@ public:
 
   Error createIndexFile(ArrayRef<std::string> SourceFiles,
                         const coverage::CoverageMapping &Coverage,
-                        const CoverageFilter &Filters) override;
+                        const CoverageFiltersMatchAll &Filters) override;
 
   CoveragePrinterHTML(const CoverageViewOptions &Opts)
       : CoveragePrinter(Opts) {}

Modified: llvm/trunk/tools/llvm-cov/SourceCoverageViewText.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/SourceCoverageViewText.cpp?rev=314782&r1=314781&r2=314782&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/SourceCoverageViewText.cpp (original)
+++ llvm/trunk/tools/llvm-cov/SourceCoverageViewText.cpp Tue Oct  3 04:05:28 2017
@@ -30,7 +30,8 @@ void CoveragePrinterText::closeViewFile(
 
 Error CoveragePrinterText::createIndexFile(
     ArrayRef<std::string> SourceFiles,
-    const coverage::CoverageMapping &Coverage, const CoverageFilter &Filters) {
+    const coverage::CoverageMapping &Coverage,
+    const CoverageFiltersMatchAll &Filters) {
   auto OSOrErr = createOutputStream("index", "txt", /*InToplevel=*/true);
   if (Error E = OSOrErr.takeError())
     return E;

Modified: llvm/trunk/tools/llvm-cov/SourceCoverageViewText.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/SourceCoverageViewText.h?rev=314782&r1=314781&r2=314782&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/SourceCoverageViewText.h (original)
+++ llvm/trunk/tools/llvm-cov/SourceCoverageViewText.h Tue Oct  3 04:05:28 2017
@@ -28,7 +28,7 @@ public:
 
   Error createIndexFile(ArrayRef<std::string> SourceFiles,
                         const coverage::CoverageMapping &Coverage,
-                        const CoverageFilter &Filters) override;
+                        const CoverageFiltersMatchAll &Filters) override;
 
   CoveragePrinterText(const CoverageViewOptions &Opts)
       : CoveragePrinter(Opts) {}




More information about the llvm-commits mailing list