[llvm-cov] Add one correction to r315960 (PR34962)
authorVedant Kumar <vsk@apple.com>
Tue, 17 Oct 2017 01:34:41 +0000 (01:34 +0000)
committerVedant Kumar <vsk@apple.com>
Tue, 17 Oct 2017 01:34:41 +0000 (01:34 +0000)
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.

llvm-svn: 315963

llvm/test/tools/llvm-cov/deferred-region.cpp
llvm/tools/llvm-cov/CoverageSummaryInfo.cpp

index 37a6ae4..895c120 100644 (file)
@@ -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|
 }
index 0fa9e5b..d1fcef4 100644 (file)
@@ -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++() {