[llvm] r315963 - [llvm-cov] Add one correction to r315960 (PR34962)

Vedant Kumar via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 16 18:34:41 PDT 2017


Author: vedantk
Date: Mon Oct 16 18:34:41 2017
New Revision: 315963

URL: http://llvm.org/viewvc/llvm-project?rev=315963&view=rev
Log:
[llvm-cov] Add one correction to r315960 (PR34962)

In r315960, I accidentally assumed that the first line segment is
guaranteed to be the non-gap region entry segment (given that one is
present). It can actually be any segment on the line, and the test I
checked in demonstrates that.

Modified:
    llvm/trunk/test/tools/llvm-cov/deferred-region.cpp
    llvm/trunk/tools/llvm-cov/CoverageSummaryInfo.cpp

Modified: llvm/trunk/test/tools/llvm-cov/deferred-region.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-cov/deferred-region.cpp?rev=315963&r1=315962&r2=315963&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-cov/deferred-region.cpp (original)
+++ llvm/trunk/test/tools/llvm-cov/deferred-region.cpp Mon Oct 16 18:34:41 2017
@@ -71,7 +71,7 @@ out: // CHECK: [[@LINE]]|{{ +}}0|
 void if_else(bool flag) {
   if (flag) { // CHECK: [[@LINE]]|{{ +}}2|
     return;   // CHECK: [[@LINE]]|{{ +}}1|
-  } else {    // CHECK: [[@LINE]]|{{ +}}2|
+  } else {    // CHECK: [[@LINE]]|{{ +}}1|
     return;   // CHECK: [[@LINE]]|{{ +}}1|
   }           // CHECK: [[@LINE]]|{{ +}}1|
 }

Modified: llvm/trunk/tools/llvm-cov/CoverageSummaryInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/CoverageSummaryInfo.cpp?rev=315963&r1=315962&r2=315963&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/CoverageSummaryInfo.cpp (original)
+++ llvm/trunk/tools/llvm-cov/CoverageSummaryInfo.cpp Mon Oct 16 18:34:41 2017
@@ -44,15 +44,14 @@ LineCoverageStats::LineCoverageStats(
     return;
 
   // Pick the max count from the non-gap, region entry segments. If there
-  // aren't any, use the wrapepd count.
-  if (HasMultipleRegions) {
-    for (const auto *LS : LineSegments)
-      if (isStartOfRegion(LS))
-        ExecutionCount = std::max(ExecutionCount, LS->Count);
+  // aren't any, use the wrapped count.
+  if (!MinRegionCount) {
+    ExecutionCount = WrappedSegment->Count;
     return;
   }
-  ExecutionCount =
-      (MinRegionCount == 1) ? LineSegments[0]->Count : WrappedSegment->Count;
+  for (const auto *LS : LineSegments)
+    if (isStartOfRegion(LS))
+      ExecutionCount = std::max(ExecutionCount, LS->Count);
 }
 
 LineCoverageIterator &LineCoverageIterator::operator++() {




More information about the llvm-commits mailing list