[llvm] r312955 - [llvm-cov] Don't attach exec counts to lines which start a skipped region

Vedant Kumar via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 11 14:31:33 PDT 2017


Author: vedantk
Date: Mon Sep 11 14:31:32 2017
New Revision: 312955

URL: http://llvm.org/viewvc/llvm-project?rev=312955&view=rev
Log:
[llvm-cov] Don't attach exec counts to lines which start a skipped region

These lines by definition don't have an execution count.

This is the final part of the fix for:
https://bugs.llvm.org/show_bug.cgi?id=34166

Added:
    llvm/trunk/test/tools/llvm-cov/Inputs/ifdef.covmapping
    llvm/trunk/test/tools/llvm-cov/Inputs/ifdef.profdata
    llvm/trunk/test/tools/llvm-cov/ifdef.c
Modified:
    llvm/trunk/tools/llvm-cov/SourceCoverageView.cpp

Added: llvm/trunk/test/tools/llvm-cov/Inputs/ifdef.covmapping
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-cov/Inputs/ifdef.covmapping?rev=312955&view=auto
==============================================================================
Binary files llvm/trunk/test/tools/llvm-cov/Inputs/ifdef.covmapping (added) and llvm/trunk/test/tools/llvm-cov/Inputs/ifdef.covmapping Mon Sep 11 14:31:32 2017 differ

Added: llvm/trunk/test/tools/llvm-cov/Inputs/ifdef.profdata
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-cov/Inputs/ifdef.profdata?rev=312955&view=auto
==============================================================================
Binary files llvm/trunk/test/tools/llvm-cov/Inputs/ifdef.profdata (added) and llvm/trunk/test/tools/llvm-cov/Inputs/ifdef.profdata Mon Sep 11 14:31:32 2017 differ

Added: llvm/trunk/test/tools/llvm-cov/ifdef.c
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-cov/ifdef.c?rev=312955&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-cov/ifdef.c (added)
+++ llvm/trunk/test/tools/llvm-cov/ifdef.c Mon Sep 11 14:31:32 2017
@@ -0,0 +1,16 @@
+// RUN: llvm-cov show -instr-profile %S/Inputs/ifdef.profdata %S/Inputs/ifdef.covmapping -dump -path-equivalence=/tmp,%S %s > %t.out 2>&1
+// RUN: FileCheck %s -input-file %t.out -check-prefix=LINE
+// RUN: FileCheck %s -input-file %t.out -check-prefix=HIGHLIGHT
+
+
+int main() {
+  if (0) { // LINE: [[@LINE]]|{{ +}}1|
+#if 0      // LINE-NEXT: [[@LINE]]|{{ +}}|
+#endif     // LINE-NEXT: [[@LINE]]|{{ +}}|
+  }
+  return 0;
+}
+
+// HIGHLIGHT: Highlighted line [[@LINE-7]], 10 -> ?
+// HIGHLIGHT-NEXT: Highlighted line [[@LINE-7]], 1 -> 1
+// HIGHLIGHT-NEXT: Highlighted line [[@LINE-6]], 1 -> 4

Modified: llvm/trunk/tools/llvm-cov/SourceCoverageView.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/SourceCoverageView.cpp?rev=312955&r1=312954&r2=312955&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/SourceCoverageView.cpp (original)
+++ llvm/trunk/tools/llvm-cov/SourceCoverageView.cpp Mon Sep 11 14:31:32 2017
@@ -95,9 +95,15 @@ LineCoverageStats::LineCoverageStats(
     if (isStartOfRegion(LineSegments[I]))
       ++MinRegionCount;
 
+  bool StartOfSkippedRegion = !LineSegments.empty() &&
+                              !LineSegments.front()->HasCount &&
+                              LineSegments.front()->IsRegionEntry;
+
   ExecutionCount = 0;
   HasMultipleRegions = MinRegionCount > 1;
-  Mapped = (WrappedSegment && WrappedSegment->HasCount) || (MinRegionCount > 0);
+  Mapped =
+      !StartOfSkippedRegion &&
+      ((WrappedSegment && WrappedSegment->HasCount) || (MinRegionCount > 0));
 
   if (!Mapped)
     return;




More information about the llvm-commits mailing list