summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/test/tools/llvm-cov/Inputs/deferred-regions.covmappingbin728 -> 796 bytes
-rw-r--r--llvm/test/tools/llvm-cov/Inputs/deferred-regions.profdatabin1208 -> 1288 bytes
-rw-r--r--llvm/test/tools/llvm-cov/deferred-region.cpp12
-rw-r--r--llvm/tools/llvm-cov/CoverageSummaryInfo.cpp23
4 files changed, 20 insertions, 15 deletions
diff --git a/llvm/test/tools/llvm-cov/Inputs/deferred-regions.covmapping b/llvm/test/tools/llvm-cov/Inputs/deferred-regions.covmapping
index 4434b66513c..d16db88acbe 100644
--- a/llvm/test/tools/llvm-cov/Inputs/deferred-regions.covmapping
+++ b/llvm/test/tools/llvm-cov/Inputs/deferred-regions.covmapping
Binary files differ
diff --git a/llvm/test/tools/llvm-cov/Inputs/deferred-regions.profdata b/llvm/test/tools/llvm-cov/Inputs/deferred-regions.profdata
index 0bacac01ccf..423f1f07cb8 100644
--- a/llvm/test/tools/llvm-cov/Inputs/deferred-regions.profdata
+++ b/llvm/test/tools/llvm-cov/Inputs/deferred-regions.profdata
Binary files differ
diff --git a/llvm/test/tools/llvm-cov/deferred-region.cpp b/llvm/test/tools/llvm-cov/deferred-region.cpp
index 6f6da7ec804..37a6ae4825c 100644
--- a/llvm/test/tools/llvm-cov/deferred-region.cpp
+++ b/llvm/test/tools/llvm-cov/deferred-region.cpp
@@ -68,6 +68,14 @@ out: // CHECK: [[@LINE]]|{{ +}}0|
return;
}
+void if_else(bool flag) {
+ if (flag) { // CHECK: [[@LINE]]|{{ +}}2|
+ return; // CHECK: [[@LINE]]|{{ +}}1|
+ } else { // CHECK: [[@LINE]]|{{ +}}2|
+ return; // CHECK: [[@LINE]]|{{ +}}1|
+ } // CHECK: [[@LINE]]|{{ +}}1|
+}
+
int main() {
foo(0);
foo(1);
@@ -75,6 +83,8 @@ int main() {
for_loop();
while_loop();
gotos();
+ if_else(true);
+ if_else(false);
return 0;
}
@@ -107,3 +117,5 @@ int main() {
// MARKER-NEXT: Highlighted line 67, 1 -> ?
// MARKER-NEXT: Highlighted line 68, 1 -> 8
// MARKER-NEXT: Highlighted line 69, 1 -> 2
+// MARKER-NEXT: Marker at 72:7 = 2
+// MARKER-NEXT: Highlighted line 77, 1 -> 2
diff --git a/llvm/tools/llvm-cov/CoverageSummaryInfo.cpp b/llvm/tools/llvm-cov/CoverageSummaryInfo.cpp
index 89948720504..0fa9e5b81bc 100644
--- a/llvm/tools/llvm-cov/CoverageSummaryInfo.cpp
+++ b/llvm/tools/llvm-cov/CoverageSummaryInfo.cpp
@@ -43,23 +43,16 @@ LineCoverageStats::LineCoverageStats(
if (!Mapped)
return;
- // Pick the max count among regions which start and end on this line, to
- // avoid erroneously using the wrapped count, and to avoid picking region
- // counts which come from deferred regions.
- if (LineSegments.size() > 1) {
- for (unsigned I = 0; I < LineSegments.size() - 1; ++I) {
- if (!LineSegments[I]->IsGapRegion)
- ExecutionCount = std::max(ExecutionCount, LineSegments[I]->Count);
- }
+ // 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);
return;
}
-
- // If a non-gap region starts here, use its count. Otherwise use the wrapped
- // count.
- if (MinRegionCount == 1)
- ExecutionCount = LineSegments[0]->Count;
- else
- ExecutionCount = WrappedSegment->Count;
+ ExecutionCount =
+ (MinRegionCount == 1) ? LineSegments[0]->Count : WrappedSegment->Count;
}
LineCoverageIterator &LineCoverageIterator::operator++() {
OpenPOWER on IntegriCloud