[llvm] r218109 - llvm-cov: Fix dropped lines when filters were applied

Justin Bogner mail at justinbogner.com
Fri Sep 19 01:13:16 PDT 2014


Author: bogner
Date: Fri Sep 19 03:13:16 2014
New Revision: 218109

URL: http://llvm.org/viewvc/llvm-project?rev=218109&view=rev
Log:
llvm-cov: Fix dropped lines when filters were applied

Uncovered lines in the middle of a covered region weren't being shown
when filtering to a particular function.

Modified:
    llvm/trunk/test/tools/llvm-cov/Inputs/lineExecutionCounts.covmapping
    llvm/trunk/test/tools/llvm-cov/showLineExecutionCounts.cpp
    llvm/trunk/tools/llvm-cov/SourceCoverageView.cpp

Modified: llvm/trunk/test/tools/llvm-cov/Inputs/lineExecutionCounts.covmapping
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-cov/Inputs/lineExecutionCounts.covmapping?rev=218109&r1=218108&r2=218109&view=diff
==============================================================================
Binary files - no diff available.

Modified: llvm/trunk/test/tools/llvm-cov/showLineExecutionCounts.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-cov/showLineExecutionCounts.cpp?rev=218109&r1=218108&r2=218109&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-cov/showLineExecutionCounts.cpp (original)
+++ llvm/trunk/test/tools/llvm-cov/showLineExecutionCounts.cpp Fri Sep 19 03:13:16 2014
@@ -1,5 +1,8 @@
-// RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -instr-profile %S/Inputs/lineExecutionCounts.profdata -no-colors -filename-equivalence %s | FileCheck %s
+// RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -instr-profile %S/Inputs/lineExecutionCounts.profdata -no-colors -filename-equivalence %s | FileCheck -check-prefix=CHECK -check-prefix=WHOLE-FILE %s
+// RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -instr-profile %S/Inputs/lineExecutionCounts.profdata -no-colors -filename-equivalence -name=main %s | FileCheck -check-prefix=CHECK -check-prefix=FILTER %s
 
+// before any coverage              // WHOLE-FILE:    | [[@LINE]]|// before
+                                    // FILTER-NOT:    | [[@LINE-1]]|// before
 int main() {                             // CHECK:   1| [[@LINE]]|int main(
   int x = 0;                             // CHECK:   1| [[@LINE]]|  int x
                                          // CHECK:   1| [[@LINE]]|
@@ -20,6 +23,8 @@ int main() {
                                          // CHECK:   1| [[@LINE]]|
   return 0;                              // CHECK:   1| [[@LINE]]|  return
 }                                        // CHECK:   1| [[@LINE]]|}
+// after coverage                   // WHOLE-FILE:    | [[@LINE]]|// after
+                                    // FILTER-NOT:    | [[@LINE-1]]|// after
 
 // llvm-cov doesn't work on big endian yet
 // XFAIL: powerpc64-, s390x, mips-, mips64-, sparc

Modified: llvm/trunk/tools/llvm-cov/SourceCoverageView.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/SourceCoverageView.cpp?rev=218109&r1=218108&r2=218109&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/SourceCoverageView.cpp (original)
+++ llvm/trunk/tools/llvm-cov/SourceCoverageView.cpp Fri Sep 19 03:13:16 2014
@@ -163,6 +163,7 @@ void SourceCoverageView::render(raw_ostr
   auto NextSegment = CoverageSegments.begin();
   auto EndSegment = CoverageSegments.end();
 
+  unsigned FirstLine = NextSegment != EndSegment ? NextSegment->Line : 0;
   const CoverageSegment *WrappedSegment = nullptr;
   SmallVector<const CoverageSegment *, 8> LineSegments;
   for (line_iterator LI(File, /*SkipBlanks=*/false); !LI.is_at_eof(); ++LI) {
@@ -171,7 +172,7 @@ void SourceCoverageView::render(raw_ostr
     if (!WholeFile) {
       if (NextSegment == EndSegment)
         break;
-      else if (LI.line_number() < NextSegment->Line)
+      else if (LI.line_number() < FirstLine)
         continue;
     }
 





More information about the llvm-commits mailing list