Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit d03e3c1

Browse files
committed
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312955 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 7d56a78 commit d03e3c1

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed
108 Bytes
Binary file not shown.
632 Bytes
Binary file not shown.

test/tools/llvm-cov/ifdef.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// RUN: llvm-cov show -instr-profile %S/Inputs/ifdef.profdata %S/Inputs/ifdef.covmapping -dump -path-equivalence=/tmp,%S %s > %t.out 2>&1
2+
// RUN: FileCheck %s -input-file %t.out -check-prefix=LINE
3+
// RUN: FileCheck %s -input-file %t.out -check-prefix=HIGHLIGHT
4+
5+
6+
int main() {
7+
if (0) { // LINE: [[@LINE]]|{{ +}}1|
8+
#if 0 // LINE-NEXT: [[@LINE]]|{{ +}}|
9+
#endif // LINE-NEXT: [[@LINE]]|{{ +}}|
10+
}
11+
return 0;
12+
}
13+
14+
// HIGHLIGHT: Highlighted line [[@LINE-7]], 10 -> ?
15+
// HIGHLIGHT-NEXT: Highlighted line [[@LINE-7]], 1 -> 1
16+
// HIGHLIGHT-NEXT: Highlighted line [[@LINE-6]], 1 -> 4

tools/llvm-cov/SourceCoverageView.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,15 @@ LineCoverageStats::LineCoverageStats(
9595
if (isStartOfRegion(LineSegments[I]))
9696
++MinRegionCount;
9797

98+
bool StartOfSkippedRegion = !LineSegments.empty() &&
99+
!LineSegments.front()->HasCount &&
100+
LineSegments.front()->IsRegionEntry;
101+
98102
ExecutionCount = 0;
99103
HasMultipleRegions = MinRegionCount > 1;
100-
Mapped = (WrappedSegment && WrappedSegment->HasCount) || (MinRegionCount > 0);
104+
Mapped =
105+
!StartOfSkippedRegion &&
106+
((WrappedSegment && WrappedSegment->HasCount) || (MinRegionCount > 0));
101107

102108
if (!Mapped)
103109
return;

0 commit comments

Comments
 (0)