[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.

llvm-svn: 315963
This commit is contained in:
Vedant Kumar 2017-10-17 01:34:41 +00:00
parent 3a5e25278a
commit 4d1969f22b
2 changed files with 7 additions and 8 deletions

View 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|
}

View 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) {
// aren't any, use the wrapped count.
if (!MinRegionCount) {
ExecutionCount = WrappedSegment->Count;
return;
}
for (const auto *LS : LineSegments)
if (isStartOfRegion(LS))
ExecutionCount = std::max(ExecutionCount, LS->Count);
return;
}
ExecutionCount =
(MinRegionCount == 1) ? LineSegments[0]->Count : WrappedSegment->Count;
}
LineCoverageIterator &LineCoverageIterator::operator++() {