summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVedant Kumar <vsk@apple.com>2017-11-09 02:33:43 +0000
committerVedant Kumar <vsk@apple.com>2017-11-09 02:33:43 +0000
commitf361756cf35f7567d56bb12621b99599a8c539e9 (patch)
treed8007efb9c8139bce06a81fa4b77ec6ee9146a1c
parent9960086c1116025fa44f27d30fa6b20f53fc5373 (diff)
[Coverage] Use the wrapped segment when a line has entry segments
We've worked around bugs in the frontend by ignoring the count from wrapped segments when a line has at least one region entry segment. Those frontend bugs are now fixed, so it's time to regenerate the checked-in covmapping files and remove the workaround. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317761 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/ProfileData/Coverage/CoverageMapping.cpp8
-rw-r--r--test/tools/llvm-cov/Inputs/deferred-regions.covmappingbin796 -> 900 bytes
-rw-r--r--test/tools/llvm-cov/Inputs/highlightedRanges.covmappingbin360 -> 336 bytes
-rw-r--r--test/tools/llvm-cov/Inputs/highlightedRanges.json11
-rw-r--r--test/tools/llvm-cov/Inputs/instrprof-comdat.h6
-rw-r--r--test/tools/llvm-cov/Inputs/lineExecutionCounts.covmappingbin172 -> 196 bytes
-rw-r--r--test/tools/llvm-cov/Inputs/prefer_used_to_unused.covmappingbin420 -> 612 bytes
-rw-r--r--test/tools/llvm-cov/Inputs/regionMarkers.covmappingbin208 -> 196 bytes
-rw-r--r--test/tools/llvm-cov/Inputs/regionMarkers.json11
-rw-r--r--test/tools/llvm-cov/Inputs/report.covmappingbin219 -> 224 bytes
-rw-r--r--test/tools/llvm-cov/Inputs/templateInstantiations.covmappingbin248 -> 316 bytes
-rw-r--r--test/tools/llvm-cov/deferred-region.cpp5
-rw-r--r--test/tools/llvm-cov/hideUnexecutedSubviews.test4
-rw-r--r--test/tools/llvm-cov/load-multiple-objects.test2
-rw-r--r--test/tools/llvm-cov/prefer_used_to_unused.h4
-rw-r--r--test/tools/llvm-cov/report.cpp22
-rw-r--r--test/tools/llvm-cov/showHighlightedRanges.cpp4
-rw-r--r--test/tools/llvm-cov/showTemplateInstantiations.cpp80
-rw-r--r--tools/llvm-cov/SourceCoverageViewHTML.cpp12
-rw-r--r--tools/llvm-cov/SourceCoverageViewText.cpp11
-rw-r--r--unittests/ProfileData/CoverageMappingTest.cpp3
21 files changed, 75 insertions, 108 deletions
diff --git a/lib/ProfileData/Coverage/CoverageMapping.cpp b/lib/ProfileData/Coverage/CoverageMapping.cpp
index ce932296997..6cde3863f18 100644
--- a/lib/ProfileData/Coverage/CoverageMapping.cpp
+++ b/lib/ProfileData/Coverage/CoverageMapping.cpp
@@ -698,12 +698,12 @@ LineCoverageStats::LineCoverageStats(
if (!Mapped)
return;
- // Pick the max count from the non-gap, region entry segments. If there
- // aren't any, use the wrapped count.
- if (!MinRegionCount) {
+ // Pick the max count from the non-gap, region entry segments and the
+ // wrapped count.
+ if (WrappedSegment)
ExecutionCount = WrappedSegment->Count;
+ if (!MinRegionCount)
return;
- }
for (const auto *LS : LineSegments)
if (isStartOfRegion(LS))
ExecutionCount = std::max(ExecutionCount, LS->Count);
diff --git a/test/tools/llvm-cov/Inputs/deferred-regions.covmapping b/test/tools/llvm-cov/Inputs/deferred-regions.covmapping
index d16db88acbe..6d7919eb8fa 100644
--- a/test/tools/llvm-cov/Inputs/deferred-regions.covmapping
+++ b/test/tools/llvm-cov/Inputs/deferred-regions.covmapping
Binary files differ
diff --git a/test/tools/llvm-cov/Inputs/highlightedRanges.covmapping b/test/tools/llvm-cov/Inputs/highlightedRanges.covmapping
index 5c1b1d61120..5c3d67f24e1 100644
--- a/test/tools/llvm-cov/Inputs/highlightedRanges.covmapping
+++ b/test/tools/llvm-cov/Inputs/highlightedRanges.covmapping
Binary files differ
diff --git a/test/tools/llvm-cov/Inputs/highlightedRanges.json b/test/tools/llvm-cov/Inputs/highlightedRanges.json
index 2948e86e453..cff6ab3e686 100644
--- a/test/tools/llvm-cov/Inputs/highlightedRanges.json
+++ b/test/tools/llvm-cov/Inputs/highlightedRanges.json
@@ -12,9 +12,9 @@
// Verify the Summary Section for the first file
// CHECK-SAME: "summary":{
-// CHECK-SAME: "lines":{"count":40,"covered":27,"percent":67},
+// CHECK-SAME: "lines":{"count":40,"covered":33,"percent":82},
// CHECK-SAME: "functions":{"count":4,"covered":4,"percent":100},
-// CHECK-SAME: "regions":{"count":19,"covered":11,"notcovered":8,"percent":57}}}
+// CHECK-SAME: "regions":{"count":21,"covered":13,"notcovered":8,"percent":61}}}
// Close Files Array
// CHECK-SAME: ],
@@ -45,10 +45,7 @@
// Full Export Summary
// CHECK-SAME: "totals":{
-// CHECK-SAME: "lines":{"count":40,"covered":27,"percent":67},
+// CHECK-SAME: "lines":{"count":40,"covered":33,"percent":82},
// CHECK-SAME: "functions":{"count":4,"covered":4,"percent":100},
// CHECK-SAME: "instantiations":{"count":4,"covered":4,"percent":100},
-// CHECK-SAME: "regions":{"count":19,"covered":11,"notcovered":8,"percent":57}}
-
-// Close the export object, data array, and root object
-// CHECK-SAME: }]}
+// CHECK-SAME: "regions":{"count":21,"covered":13,"notcovered":8,"percent":61}}}
diff --git a/test/tools/llvm-cov/Inputs/instrprof-comdat.h b/test/tools/llvm-cov/Inputs/instrprof-comdat.h
index 5a6d72b248a..07941f9bb49 100644
--- a/test/tools/llvm-cov/Inputs/instrprof-comdat.h
+++ b/test/tools/llvm-cov/Inputs/instrprof-comdat.h
@@ -12,7 +12,7 @@ template <class T> T FOO<T>::DoIt(T ti) { // HEADER: [[@LINE]]| 2|template
for (T I = 0; I < ti; I++) { // HEADER: [[@LINE]]| 22| for (T
t += I; // HEADER: [[@LINE]]| 20| t += I;
if (I > ti / 2) // HEADER: [[@LINE]]| 20| if (I > ti
- t -= 1; // HEADER: [[@LINE]]| 8| t -= 1;
+ t -= 1; // HEADER: [[@LINE]]| 20| t -= 1;
} // HEADER: [[@LINE]]| 20| }
// HEADER: [[@LINE]]| 2|
return t; // HEADER: [[@LINE]]| 2| return t;
@@ -22,3 +22,7 @@ template <class T> T FOO<T>::DoIt(T ti) { // HEADER: [[@LINE]]| 2|template
// compile a program with two calls to Foo<int>::DoIt(10) for each desired
// architecture. Collect a raw profile from any one of these binaries, index
// it, and check it in along with the executables.
+
+// Note:
+// The line execution count on line 14 is incorrect because of a bug in the
+// checked-in coverage mappings, which has subsequently been fixed in clang.
diff --git a/test/tools/llvm-cov/Inputs/lineExecutionCounts.covmapping b/test/tools/llvm-cov/Inputs/lineExecutionCounts.covmapping
index f70ea0528db..0b2458ae4fd 100644
--- a/test/tools/llvm-cov/Inputs/lineExecutionCounts.covmapping
+++ b/test/tools/llvm-cov/Inputs/lineExecutionCounts.covmapping
Binary files differ
diff --git a/test/tools/llvm-cov/Inputs/prefer_used_to_unused.covmapping b/test/tools/llvm-cov/Inputs/prefer_used_to_unused.covmapping
index 4722129fc18..134067e9194 100644
--- a/test/tools/llvm-cov/Inputs/prefer_used_to_unused.covmapping
+++ b/test/tools/llvm-cov/Inputs/prefer_used_to_unused.covmapping
Binary files differ
diff --git a/test/tools/llvm-cov/Inputs/regionMarkers.covmapping b/test/tools/llvm-cov/Inputs/regionMarkers.covmapping
index 1c9b5dd45c7..af920c2d169 100644
--- a/test/tools/llvm-cov/Inputs/regionMarkers.covmapping
+++ b/test/tools/llvm-cov/Inputs/regionMarkers.covmapping
Binary files differ
diff --git a/test/tools/llvm-cov/Inputs/regionMarkers.json b/test/tools/llvm-cov/Inputs/regionMarkers.json
index 0589f7b6626..c9964338947 100644
--- a/test/tools/llvm-cov/Inputs/regionMarkers.json
+++ b/test/tools/llvm-cov/Inputs/regionMarkers.json
@@ -12,9 +12,9 @@
// Verify the Summary Section for the first file
// CHECK-SAME: "summary":{
-// CHECK-SAME: "lines":{"count":21,"covered":18,"percent":85},
+// CHECK-SAME: "lines":{"count":21,"covered":19,"percent":90},
// CHECK-SAME: "functions":{"count":1,"covered":1,"percent":100},
-// CHECK-SAME: "regions":{"count":10,"covered":7,"notcovered":3,"percent":70}}
+// CHECK-SAME: "regions":{"count":11,"covered":8,"notcovered":3,"percent":72}}
// Close Files Array
// CHECK-SAME: ],
@@ -29,10 +29,7 @@
// Full Export Summary
// CHECK-SAME: "totals":{
-// CHECK-SAME: "lines":{"count":21,"covered":18,"percent":85},
+// CHECK-SAME: "lines":{"count":21,"covered":19,"percent":90},
// CHECK-SAME: "functions":{"count":1,"covered":1,"percent":100},
// CHECK-SAME: "instantiations":{"count":1,"covered":1,"percent":100},
-// CHECK-SAME: "regions":{"count":10,"covered":7,"notcovered":3,"percent":70}}
-
-// Close the export object, data array, and root object
-// CHECK-SAME: }]}
+// CHECK-SAME: "regions":{"count":11,"covered":8,"notcovered":3,"percent":72}}
diff --git a/test/tools/llvm-cov/Inputs/report.covmapping b/test/tools/llvm-cov/Inputs/report.covmapping
index 5d0bfc11681..f9858ed272b 100644
--- a/test/tools/llvm-cov/Inputs/report.covmapping
+++ b/test/tools/llvm-cov/Inputs/report.covmapping
Binary files differ
diff --git a/test/tools/llvm-cov/Inputs/templateInstantiations.covmapping b/test/tools/llvm-cov/Inputs/templateInstantiations.covmapping
index 2dfc6cddbe7..b604e0604ad 100644
--- a/test/tools/llvm-cov/Inputs/templateInstantiations.covmapping
+++ b/test/tools/llvm-cov/Inputs/templateInstantiations.covmapping
Binary files differ
diff --git a/test/tools/llvm-cov/deferred-region.cpp b/test/tools/llvm-cov/deferred-region.cpp
index 09d9d09a09d..a3f6b01332c 100644
--- a/test/tools/llvm-cov/deferred-region.cpp
+++ b/test/tools/llvm-cov/deferred-region.cpp
@@ -93,8 +93,6 @@ int main() {
// MARKER-NEXT: Marker at 19:27 = 1
// MARKER-NEXT: Highlighted line 24, 7 -> 12
// MARKER-NEXT: Highlighted line 36, 5 -> 11
-// MARKER-NEXT: Highlighted line 46, 1 -> ?
-// MARKER-NEXT: Highlighted line 47, 1 -> 7
// MARKER-NEXT: Highlighted line 47, 7 -> 14
// MARKER-NEXT: Highlighted line 47, 14 -> 21
// MARKER-NEXT: Highlighted line 47, 21 -> 23
@@ -105,6 +103,3 @@ int main() {
// MARKER-NEXT: Highlighted line 63, 5 -> 13
// MARKER-NEXT: Highlighted line 67, 1 -> ?
// MARKER-NEXT: Highlighted line 68, 1 -> 8
-// MARKER-NEXT: Highlighted line 68, 8 -> ?
-// MARKER-NEXT: Highlighted line 69, 1 -> 2
-// MARKER-NEXT: Highlighted line 77, 1 -> 2
diff --git a/test/tools/llvm-cov/hideUnexecutedSubviews.test b/test/tools/llvm-cov/hideUnexecutedSubviews.test
index 20f0a43fc02..e972a19d58c 100644
--- a/test/tools/llvm-cov/hideUnexecutedSubviews.test
+++ b/test/tools/llvm-cov/hideUnexecutedSubviews.test
@@ -5,8 +5,8 @@ RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %t
RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %t.profdata -format html -show-region-summary -show-instantiation-summary -o %t.html.dir -path-equivalence=/tmp,%S %S/showTemplateInstantiations.cpp
RUN: FileCheck -check-prefix=FILE %s -input-file %t.html.dir/coverage/tmp/showTemplateInstantiations.cpp.html
-FILE: Unexecuted instantiation: _Z4funcIbEiT_
FILE: Unexecuted instantiation: _Z4funcIiEiT_
+FILE: Unexecuted instantiation: _Z4funcIbEiT_
FILE-NOT: Unexecuted instantiation
RUN: FileCheck -check-prefix=INDEX %s -input-file %t.html.dir/index.html
@@ -23,4 +23,4 @@ INDEX: 33.33% (1/3)
INDEX: <td class='column-entry-red'>
INDEX: 41.67% (5/12)
INDEX: <td class='column-entry-red'>
-INDEX: 20.00% (1/5)
+INDEX: 16.67% (1/6)
diff --git a/test/tools/llvm-cov/load-multiple-objects.test b/test/tools/llvm-cov/load-multiple-objects.test
index 55fed31366c..41eae1926b1 100644
--- a/test/tools/llvm-cov/load-multiple-objects.test
+++ b/test/tools/llvm-cov/load-multiple-objects.test
@@ -4,8 +4,8 @@
// RUN: llvm-cov report %S/Inputs/multiple-files.covmapping -object %S/Inputs/highlightedRanges.covmapping -instr-profile %t.profdata | FileCheck %s -check-prefixes=OBJ1,OBJ2
-// OBJ2: showHighlightedRanges.cpp
// OBJ1: f2.c
// OBJ1: f4.c
// OBJ1: f3.c
// OBJ1: f1.c
+// OBJ2: showHighlightedRanges.cpp
diff --git a/test/tools/llvm-cov/prefer_used_to_unused.h b/test/tools/llvm-cov/prefer_used_to_unused.h
index 852eb927a5c..4d5e18c9e77 100644
--- a/test/tools/llvm-cov/prefer_used_to_unused.h
+++ b/test/tools/llvm-cov/prefer_used_to_unused.h
@@ -9,14 +9,14 @@
// llvm-cov convert-for-testing -o prefer_used_to_unused.covmapping tmp
// RUN: llvm-profdata merge %S/Inputs/prefer_used_to_unused.proftext -o %t.profdata
-// RUN: llvm-cov show %S/Inputs/prefer_used_to_unused.covmapping -instr-profile %t.profdata -path-equivalence=/tmp/uu/./,%S %s | FileCheck %s
+// RUN: llvm-cov show %S/Inputs/prefer_used_to_unused.covmapping -instr-profile %t.profdata -path-equivalence=/tmp/,%S %s | FileCheck %s
// Coverage data for this function has a non-zero hash value if it is used in the translation unit.
inline int sampleFunc(int A) { // CHECK: [[@LINE]]| 1|inline int sampleFunc(int A) {
if (A > 0) // CHECK-NEXT: [[@LINE]]| 1| if (A > 0)
return A; // CHECK-NEXT: [[@LINE]]| 1| return A;
return 0; // CHECK-NEXT: [[@LINE]]| 0| return 0;
-} // CHECK-NEXT: [[@LINE]]| 1|}
+} // CHECK-NEXT: [[@LINE]]| 0|}
// The hash for this function is zero in both cases, either it is used in the translation unit or not.
inline int simpleFunc(int A) { // CHECK: [[@LINE]]| 1|inline int simpleFunc(int A) {
diff --git a/test/tools/llvm-cov/report.cpp b/test/tools/llvm-cov/report.cpp
index be7b5ea9568..6676ed812b0 100644
--- a/test/tools/llvm-cov/report.cpp
+++ b/test/tools/llvm-cov/report.cpp
@@ -1,25 +1,25 @@
-// RUN: llvm-cov report %S/Inputs/report.covmapping -instr-profile %S/Inputs/report.profdata -path-equivalence=,%S 2>&1 -show-region-summary -show-instantiation-summary | FileCheck %s
-// RUN: llvm-cov report -show-functions %S/Inputs/report.covmapping -instr-profile %S/Inputs/report.profdata -path-equivalence=,%S %s 2>&1 | FileCheck -check-prefix=FILT %s
-// RUN: llvm-cov report -show-functions %S/Inputs/report.covmapping -instr-profile %S/Inputs/report.profdata -path-equivalence=,%S %s does-not-exist.cpp 2>&1 | FileCheck -check-prefix=FILT %s
-// RUN: not llvm-cov report -show-functions %S/Inputs/report.covmapping -instr-profile %S/Inputs/report.profdata -path-equivalence=,%S 2>&1 | FileCheck -check-prefix=NO_FILES %s
+// RUN: llvm-cov report %S/Inputs/report.covmapping -instr-profile %S/Inputs/report.profdata -path-equivalence=/tmp,%S 2>&1 -show-region-summary -show-instantiation-summary | FileCheck %s
+// RUN: llvm-cov report -show-functions %S/Inputs/report.covmapping -instr-profile %S/Inputs/report.profdata -path-equivalence=/tmp,%S %s 2>&1 | FileCheck -check-prefix=FILT %s
+// RUN: llvm-cov report -show-functions %S/Inputs/report.covmapping -instr-profile %S/Inputs/report.profdata -path-equivalence=/tmp,%S %s does-not-exist.cpp 2>&1 | FileCheck -check-prefix=FILT %s
+// RUN: not llvm-cov report -show-functions %S/Inputs/report.covmapping -instr-profile %S/Inputs/report.profdata -path-equivalence=/tmp,%S 2>&1 | FileCheck -check-prefix=NO_FILES %s
// NO_FILES: Source files must be specified when -show-functions=true is specified
// CHECK: Regions Missed Regions Cover Functions Missed Functions Executed Instantiations Missed Insts. Executed Lines Missed Lines Cover
// CHECK-NEXT: ---
-// CHECK-NEXT: report.cpp 5 2 60.00% 4 1 75.00% 4 1 75.00% 13 4 69.23%
+// CHECK-NEXT: report.cpp 6 2 66.67% 4 1 75.00% 4 1 75.00% 13 3 76.92%
// CHECK-NEXT: ---
-// CHECK-NEXT: TOTAL 5 2 60.00% 4 1 75.00% 4 1 75.00% 13 4 69.23%
+// CHECK-NEXT: TOTAL 6 2 66.67% 4 1 75.00% 4 1 75.00% 13 3 76.92%
-// FILT: File 'report.cpp':
+// FILT: File '{{.*}}report.cpp':
// FILT-NEXT: Name Regions Miss Cover Lines Miss Cover
// FILT-NEXT: ---
-// FILT-NEXT: _Z3foob 2 1 50.00% 4 2 50.00%
+// FILT-NEXT: _Z3foob 3 1 66.67% 4 1 75.00%
// FILT-NEXT: _Z3barv 1 0 100.00% 2 0 100.00%
// FILT-NEXT: _Z4funcv 1 1 0.00% 2 2 0.00%
// FILT-NEXT: main 1 0 100.00% 5 0 100.00%
// FILT-NEXT: ---
-// FILT-NEXT: TOTAL 5 2 60.00% 13 4 69.23%
+// FILT-NEXT: TOTAL 6 2 66.67% 13 3 76.92%
void foo(bool cond) {
if (cond) {
@@ -39,8 +39,8 @@ int main() {
}
// Test that listing multiple functions in a function view works.
-// RUN: llvm-cov show -o %t.dir %S/Inputs/report.covmapping -instr-profile=%S/Inputs/report.profdata -path-equivalence=,%S -name-regex=".*" %s
-// RUN: FileCheck -check-prefix=FUNCTIONS -input-file %t.dir/coverage/report.cpp.txt %s
+// RUN: llvm-cov show -o %t.dir %S/Inputs/report.covmapping -instr-profile=%S/Inputs/report.profdata -path-equivalence=/tmp,%S -name-regex=".*" %s
+// RUN: FileCheck -check-prefix=FUNCTIONS -input-file %t.dir/coverage/tmp/report.cpp.txt %s
// FUNCTIONS: _Z3foob
// FUNCTIONS: _Z3barv
// FUNCTIONS: _Z4func
diff --git a/test/tools/llvm-cov/showHighlightedRanges.cpp b/test/tools/llvm-cov/showHighlightedRanges.cpp
index bfcdf76f4ad..f225816b0f6 100644
--- a/test/tools/llvm-cov/showHighlightedRanges.cpp
+++ b/test/tools/llvm-cov/showHighlightedRanges.cpp
@@ -1,4 +1,4 @@
-// RUN: llvm-cov show %S/Inputs/highlightedRanges.covmapping -instr-profile %S/Inputs/highlightedRanges.profdata -dump -path-equivalence=/Users/bogner/code/llvm/test/tools,%S/.. %s 2>&1 | FileCheck %s -check-prefixes=TEXT,SHARED
+// RUN: llvm-cov show %S/Inputs/highlightedRanges.covmapping -instr-profile %S/Inputs/highlightedRanges.profdata -dump -path-equivalence=/tmp,%S %s 2>&1 | FileCheck %s -check-prefixes=TEXT,SHARED
void func() {
return;
@@ -44,5 +44,5 @@ int main() {
return 0;
}
-// RUN: llvm-cov show %S/Inputs/highlightedRanges.covmapping -instr-profile %S/Inputs/highlightedRanges.profdata -format html -dump -path-equivalence=/Users/bogner/code/llvm/test/tools,%S/.. %s 2>&1 | FileCheck %s -check-prefixes=HTML,SHARED
+// RUN: llvm-cov show %S/Inputs/highlightedRanges.covmapping -instr-profile %S/Inputs/highlightedRanges.profdata -format html -dump -path-equivalence=/tmp,%S %s 2>&1 | FileCheck %s -check-prefixes=HTML,SHARED
// RUN: llvm-cov export %S/Inputs/highlightedRanges.covmapping -instr-profile %S/Inputs/highlightedRanges.profdata 2>&1 | FileCheck %S/Inputs/highlightedRanges.json
diff --git a/test/tools/llvm-cov/showTemplateInstantiations.cpp b/test/tools/llvm-cov/showTemplateInstantiations.cpp
index 428ceac7dba..380e98b42bb 100644
--- a/test/tools/llvm-cov/showTemplateInstantiations.cpp
+++ b/test/tools/llvm-cov/showTemplateInstantiations.cpp
@@ -7,29 +7,29 @@ template<typename T> // ALL: [[@LINE]]| |template<typename T>
int func(T x) { // ALL-NEXT: [[@LINE]]| 2|int func(T x) {
if(x) // ALL-NEXT: [[@LINE]]| 2| if(x)
return 0; // ALL-NEXT: [[@LINE]]| 1| return 0;
- else // ALL-NEXT: [[@LINE]]| 2| else
+ else // ALL-NEXT: [[@LINE]]| 1| else
return 1; // ALL-NEXT: [[@LINE]]| 1| return 1;
int j = 1; // ALL-NEXT: [[@LINE]]| 0| int j = 1;
-} // ALL-NEXT: [[@LINE]]| 2|}
+} // ALL-NEXT: [[@LINE]]| 0|}
- // SHARED: {{^ *(\| )?}}_Z4funcIbEiT_:
- // SHARED: [[@LINE-9]]| 1|int func(T x) {
- // SHARED-NEXT: [[@LINE-9]]| 1| if(x)
- // SHARED-NEXT: [[@LINE-9]]| 1| return 0;
- // SHARED-NEXT: [[@LINE-9]]| 1| else
- // SHARED-NEXT: [[@LINE-9]]| 0| return 1;
- // SHARED-NEXT: [[@LINE-9]]| 0| int j = 1;
- // SHARED-NEXT: [[@LINE-9]]| 1|}
+ // ALL: _Z4{{[a-z]+}}IiEiT_:
+ // FILTER-NOT: _Z4{{[a-z]+}}IiEiT_:
+ // ALL: [[@LINE-10]]| 1|int func(T x) {
+ // ALL-NEXT: [[@LINE-10]]| 1| if(x)
+ // ALL-NEXT: [[@LINE-10]]| 0| return 0;
+ // ALL-NEXT: [[@LINE-10]]| 1| else
+ // ALL-NEXT: [[@LINE-10]]| 1| return 1;
+ // ALL-NEXT: [[@LINE-10]]| 0| int j = 1;
+ // ALL-NEXT: [[@LINE-10]]| 0|}
- // ALL: {{^ *}}| _Z4funcIiEiT_:
- // FILTER-NOT: {{^ *(\| )?}} _Z4funcIiEiT_:
- // ALL: [[@LINE-19]]| 1|int func(T x) {
- // ALL-NEXT: [[@LINE-19]]| 1| if(x)
- // ALL-NEXT: [[@LINE-19]]| 0| return 0;
- // ALL-NEXT: [[@LINE-19]]| 1| else
- // ALL-NEXT: [[@LINE-19]]| 1| return 1;
- // ALL-NEXT: [[@LINE-19]]| 0| int j = 1;
- // ALL-NEXT: [[@LINE-19]]| 1|}
+ // SHARED: {{^ *(\| )?}}_Z4funcIbEiT_:
+ // SHARED: [[@LINE-19]]| 1|int func(T x) {
+ // SHARED-NEXT: [[@LINE-19]]| 1| if(x)
+ // SHARED-NEXT: [[@LINE-19]]| 1| return 0;
+ // SHARED-NEXT: [[@LINE-19]]| 0| else
+ // SHARED-NEXT: [[@LINE-19]]| 0| return 1;
+ // SHARED-NEXT: [[@LINE-19]]| 0| int j = 1;
+ // SHARED-NEXT: [[@LINE-19]]| 0|}
int main() { // ALL: [[@LINE]]| 1|int main() {
func<int>(0); // ALL-NEXT: [[@LINE]]| 1| func<int>(0);
@@ -45,44 +45,16 @@ int main() { // ALL: [[@LINE]]| 1|int main() {
// RUN: FileCheck -check-prefixes=HTML-SHARED,HTML-ALL -input-file=%t.html.dir/coverage/tmp/showTemplateInstantiations.cpp.html %s
// RUN: FileCheck -check-prefixes=HTML-SHARED,HTML-FILTER -input-file=%t.html.filtered.dir/coverage/tmp/showTemplateInstantiations.cpp.html %s
-// HTML-ALL: <td class='line-number'><a name='L[[@LINE-44]]' href='#L[[@LINE-44]]'><pre>[[@LINE-44]]</pre></a></td><td class='uncovered-line'></td><td class='code'><pre>// before
-// HTML-FILTER-NOT: <td class='line-number'><a name='L[[@LINE-45]]' href='#L[[@LINE-45]]'><pre>[[@LINE-45]]</pre></a></td><td class='uncovered-line'></td><td class='code'><pre>// before
-// HTML-ALL: <td class='line-number'><a name='L[[@LINE-44]]' href='#L[[@LINE-44]]'><pre>[[@LINE-44]]</pre></a></td><td class='uncovered-line'></td><td class='code'><pre>template&lt;typename T&gt;
-// HTML-ALL: <td class='line-number'><a name='L[[@LINE-44]]' href='#L[[@LINE-44]]'><pre>[[@LINE-44]]</pre></a></td><td class='covered-line'><pre>2</pre></td><td class='code'><pre>int func(T x) {
-// HTML-ALL: <td class='line-number'><a name='L[[@LINE-44]]' href='#L[[@LINE-44]]'><pre>[[@LINE-44]]</pre></a></td><td class='covered-line'><pre>2</pre></td><td class='code'><pre> if(x)
-// HTML-ALL: <td class='line-number'><a name='L[[@LINE-44]]' href='#L[[@LINE-44]]'><pre>[[@LINE-44]]</pre></a></td><td class='covered-line'><pre>1</pre></td><td class='code'><pre> ret
-// HTML-ALL: <td class='line-number'><a name='L[[@LINE-44]]' href='#L[[@LINE-44]]'><pre>[[@LINE-44]]</pre></a></td><td class='covered-line'><pre>2</pre></td><td class='code'><pre> else
-// HTML-ALL: <td class='line-number'><a name='L[[@LINE-44]]' href='#L[[@LINE-44]]'><pre>[[@LINE-44]]</pre></a></td><td class='covered-line'><pre>1</pre></td><td class='code'><pre> ret
-// HTML-ALL: <td class='line-number'><a name='L[[@LINE-44]]' href='#L[[@LINE-44]]'><pre>[[@LINE-44]]</pre></a></td><td class='uncovered-line'><pre>0</pre></td><td class='code'><pre>
-// HTML-ALL: <td class='line-number'><a name='L[[@LINE-44]]' href='#L[[@LINE-44]]'><pre>[[@LINE-44]]</pre></a></td><td class='covered-line'><pre>2</pre></td><td class='code'><pre>}
-
-// HTML-SHARED: <div class='source-name-title'><pre>_Z4funcIbEiT_</pre></div>
-// HTML-SHARED: <td class='line-number'><a name='L[[@LINE-53]]' href='#L[[@LINE-53]]'><pre>[[@LINE-53]]</pre></a></td><td class='covered-line'><pre>1</pre></td><td class='code'><pre>int func(T x) {
-// HTML-SHARED: <td class='line-number'><a name='L[[@LINE-53]]' href='#L[[@LINE-53]]'><pre>[[@LINE-53]]</pre></a></td><td class='covered-line'><pre>1</pre></td><td class='code'><pre> if(x)
-// HTML-SHARED: <td class='line-number'><a name='L[[@LINE-53]]' href='#L[[@LINE-53]]'><pre>[[@LINE-53]]</pre></a></td><td class='covered-line'><pre>1</pre></td><td class='code'><pre> ret
-// HTML-SHARED: <td class='line-number'><a name='L[[@LINE-53]]' href='#L[[@LINE-53]]'><pre>[[@LINE-53]]</pre></a></td><td class='covered-line'><pre>1</pre></td><td class='code'><pre> else
-// HTML-SHARED: <td class='line-number'><a name='L[[@LINE-53]]' href='#L[[@LINE-53]]'><pre>[[@LINE-53]]</pre></a></td><td class='uncovered-line'><pre>0</pre></td><td class='code'><pre>
-// HTML-SHARED: <td class='line-number'><a name='L[[@LINE-53]]' href='#L[[@LINE-53]]'><pre>[[@LINE-53]]</pre></a></td><td class='uncovered-line'><pre>0</pre></td><td class='code'><pre>
-// HTML-SHARED: <td class='line-number'><a name='L[[@LINE-53]]' href='#L[[@LINE-53]]'><pre>[[@LINE-53]]</pre></a></td><td class='covered-line'><pre>1</pre></td><td class='code'><pre>}
+// HTML-ALL: <td class='line-number'><a name='L4' href='#L4'><pre>4</pre></a></td><td class='uncovered-line'></td><td class='code'><pre>// before
+// HTML-FILTER-NOT: <td class='line-number'><a name='L4' href='#L4'><pre>4</pre></a></td><td class='uncovered-line'></td><td class='code'><pre>// before
+// HTML-ALL: <td class='line-number'><a name='L6' href='#L6'><pre>6</pre></a></td><td class='uncovered-line'></td><td class='code'><pre>template&lt;typename T&gt;
// HTML-ALL: <div class='source-name-title'><pre>_Z4funcIiEiT_</pre></div>
// HTML-FILTER-NOT: <div class='source-name-title'><pre>_Z4funcIiEiT_</pre></div><table>
-// HTML-ALL: <td class='line-number'><a name='L[[@LINE-63]]' href='#L[[@LINE-63]]'><pre>[[@LINE-63]]</pre></a></td><td class='covered-line'><pre>1</pre></td><td class='code'><pre>int func(T x) {
-// HTML-ALL: <td class='line-number'><a name='L[[@LINE-63]]' href='#L[[@LINE-63]]'><pre>[[@LINE-63]]</pre></a></td><td class='covered-line'><pre>1</pre></td><td class='code'><pre> if(x)
-// HTML-ALL: <td class='line-number'><a name='L[[@LINE-63]]' href='#L[[@LINE-63]]'><pre>[[@LINE-63]]</pre></a></td><td class='uncovered-line'><pre>0</pre></td><td class='code'><pre>
-// HTML-ALL: <td class='line-number'><a name='L[[@LINE-63]]' href='#L[[@LINE-63]]'><pre>[[@LINE-63]]</pre></a></td><td class='covered-line'><pre>1</pre></td><td class='code'><pre> else
-// HTML-ALL: <td class='line-number'><a name='L[[@LINE-63]]' href='#L[[@LINE-63]]'><pre>[[@LINE-63]]</pre></a></td><td class='covered-line'><pre>1</pre></td><td class='code'><pre> ret
-// HTML-ALL: <td class='line-number'><a name='L[[@LINE-63]]' href='#L[[@LINE-63]]'><pre>[[@LINE-63]]</pre></a></td><td class='uncovered-line'><pre>0</pre></td><td class='code'><pre>
-// HTML-ALL: <td class='line-number'><a name='L[[@LINE-63]]' href='#L[[@LINE-63]]'><pre>[[@LINE-63]]</pre></a></td><td class='covered-line'><pre>1</pre></td><td class='code'><pre>}
-
-// HTML-ALL: <td class='line-number'><a name='L[[@LINE-44]]' href='#L[[@LINE-44]]'><pre>[[@LINE-44]]</pre></a></td><td class='covered-line'><pre>1</pre></td><td class='code'><pre>int main() {
-// HTML-ALL: <td class='line-number'><a name='L[[@LINE-44]]' href='#L[[@LINE-44]]'><pre>[[@LINE-44]]</pre></a></td><td class='covered-line'><pre>1</pre></td><td class='code'><pre> func&lt;int&gt;(0);
-// HTML-ALL: <td class='line-number'><a name='L[[@LINE-44]]' href='#L[[@LINE-44]]'><pre>[[@LINE-44]]</pre></a></td><td class='covered-line'><pre>1</pre></td><td class='code'><pre> func&lt;bool&gt;(true);
-// HTML-ALL: <td class='line-number'><a name='L[[@LINE-44]]' href='#L[[@LINE-44]]'><pre>[[@LINE-44]]</pre></a></td><td class='covered-line'><pre>1</pre></td><td class='code'><pre> return 0;
-// HTML-ALL: <td class='line-number'><a name='L[[@LINE-44]]' href='#L[[@LINE-44]]'><pre>[[@LINE-44]]</pre></a></td><td class='covered-line'><pre>1</pre></td><td class='code'><pre>}
+// HTML-ALL: <td class='line-number'><a name='L7' href='#L7'><pre>7</pre></a></td><td class='covered-line'><pre>1</pre></td><td class='code'><pre>int func(T x) {
-// HTML-ALL: <td class='line-number'><a name='L[[@LINE-45]]' href='#L[[@LINE-45]]'><pre>[[@LINE-45]]</pre></a></td><td class='uncovered-line'></td><td class='code'><pre>// after
-// HTML-FILTER-NOT: <td class='line-number'><a name='L[[@LINE-46]]' href='#L[[@LINE-46]]'><pre>[[@LINE-46]]</pre></a></td><td class='uncovered-line'></td><td class='code'><pre>// after
+// HTML-SHARED: <div class='source-name-title'><pre>_Z4funcIbEiT_</pre></div>
+// HTML-SHARED: <td class='line-number'><a name='L7' href='#L7'><pre>7</pre></a></td><td class='covered-line'><pre>1</pre></td><td class='code'><pre>int func(T x) {
// RUN: FileCheck -check-prefix=HTML-JUMP -input-file=%t.html.dir/coverage/tmp/showTemplateInstantiations.cpp.html %s
// HTML-JUMP: <pre>Source (<a href='#L{{[0-9]+}}'>jump to first uncovered line</a>)</pre>
@@ -93,5 +65,5 @@ int main() { // ALL: [[@LINE]]| 1|int main() {
// NO_INSTS-NOT: {{^ *}}| _Z4funcIiEiT_:
// RUN: llvm-cov report %S/Inputs/templateInstantiations.covmapping -dump -instr-profile %S/Inputs/templateInstantiations.profdata -path-equivalence=/tmp,%S %s | FileCheck -check-prefix=DUMP %s
-// DUMP: InstantiationGroup: Definition at line 7, column 30 with size = 2
+// DUMP: InstantiationGroup: Definition at line 7, column 15 with size = 2
// DUMP: InstantiationGroup: main with size = 1
diff --git a/tools/llvm-cov/SourceCoverageViewHTML.cpp b/tools/llvm-cov/SourceCoverageViewHTML.cpp
index e83918474cb..7e9fc238dbe 100644
--- a/tools/llvm-cov/SourceCoverageViewHTML.cpp
+++ b/tools/llvm-cov/SourceCoverageViewHTML.cpp
@@ -514,8 +514,9 @@ void SourceCoverageViewHTML::renderLine(raw_ostream &OS, LineRef L,
return tag("span", Snippet, Color.getValue());
};
- auto CheckIfUncovered = [](const CoverageSegment *S) {
- return S && S->HasCount && S->Count == 0;
+ auto CheckIfUncovered = [&](const CoverageSegment *S) {
+ return S && (!S->IsGapRegion || (Color && *Color == "red")) &&
+ S->HasCount && S->Count == 0;
};
if (CheckIfUncovered(LCS.getWrappedSegment())) {
@@ -526,11 +527,10 @@ void SourceCoverageViewHTML::renderLine(raw_ostream &OS, LineRef L,
for (unsigned I = 0, E = Segments.size(); I < E; ++I) {
const auto *CurSeg = Segments[I];
- if (CurSeg->Col == ExpansionCol)
- Color = "cyan";
- else if ((!CurSeg->IsGapRegion || (Color && *Color == "red")) &&
- CheckIfUncovered(CurSeg))
+ if (CheckIfUncovered(CurSeg))
Color = "red";
+ else if (CurSeg->Col == ExpansionCol)
+ Color = "cyan";
else
Color = None;
diff --git a/tools/llvm-cov/SourceCoverageViewText.cpp b/tools/llvm-cov/SourceCoverageViewText.cpp
index 4b69b08e5a5..2480ee9f416 100644
--- a/tools/llvm-cov/SourceCoverageViewText.cpp
+++ b/tools/llvm-cov/SourceCoverageViewText.cpp
@@ -106,7 +106,8 @@ void SourceCoverageViewText::renderLine(raw_ostream &OS, LineRef L,
SmallVector<std::pair<unsigned, unsigned>, 2> HighlightedRanges;
// The first segment overlaps from a previous line, so we treat it specially.
- if (WrappedSegment && WrappedSegment->HasCount && WrappedSegment->Count == 0)
+ if (WrappedSegment && !WrappedSegment->IsGapRegion &&
+ WrappedSegment->HasCount && WrappedSegment->Count == 0)
Highlight = raw_ostream::RED;
// Output each segment of the line, possibly highlighted.
@@ -120,11 +121,11 @@ void SourceCoverageViewText::renderLine(raw_ostream &OS, LineRef L,
if (getOptions().Debug && Highlight)
HighlightedRanges.push_back(std::make_pair(Col, End));
Col = End;
- if (Col == ExpansionCol)
- Highlight = raw_ostream::CYAN;
- else if ((!S->IsGapRegion || Highlight == raw_ostream::RED) &&
- S->HasCount && S->Count == 0)
+ if ((!S->IsGapRegion || (Highlight && *Highlight == raw_ostream::RED)) &&
+ S->HasCount && S->Count == 0)
Highlight = raw_ostream::RED;
+ else if (Col == ExpansionCol)
+ Highlight = raw_ostream::CYAN;
else
Highlight = None;
}
diff --git a/unittests/ProfileData/CoverageMappingTest.cpp b/unittests/ProfileData/CoverageMappingTest.cpp
index ce52c6f93ee..7c94ece1adc 100644
--- a/unittests/ProfileData/CoverageMappingTest.cpp
+++ b/unittests/ProfileData/CoverageMappingTest.cpp
@@ -648,9 +648,10 @@ TEST_P(CoverageMappingTest, test_line_coverage_iterator) {
CoverageData Data = LoadedCoverage->getCoverageForFile("file1");
unsigned Line = 0;
- unsigned LineCounts[] = {20, 20, 20, 20, 10, 10, 10, 10, 10, 0, 0};
+ unsigned LineCounts[] = {20, 20, 20, 20, 30, 10, 10, 10, 10, 0, 0};
for (const auto &LCS : getLineCoverageStats(Data)) {
ASSERT_EQ(Line + 1, LCS.getLine());
+ errs() << "Line: " << Line + 1 << ", count = " << LCS.getExecutionCount() << "\n";
ASSERT_EQ(LineCounts[Line], LCS.getExecutionCount());
++Line;
}