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 Binary files a/test/tools/llvm-cov/Inputs/deferred-regions.covmapping and b/test/tools/llvm-cov/Inputs/deferred-regions.covmapping differ diff --git a/test/tools/llvm-cov/Inputs/highlightedRanges.covmapping b/test/tools/llvm-cov/Inputs/highlightedRanges.covmapping index 5c1b1d61120..5c3d67f24e1 100644 Binary files a/test/tools/llvm-cov/Inputs/highlightedRanges.covmapping and b/test/tools/llvm-cov/Inputs/highlightedRanges.covmapping 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 T FOO::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 T FOO::DoIt(T ti) { // HEADER: [[@LINE]]| 2|template // compile a program with two calls to Foo::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 Binary files a/test/tools/llvm-cov/Inputs/lineExecutionCounts.covmapping and b/test/tools/llvm-cov/Inputs/lineExecutionCounts.covmapping 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 Binary files a/test/tools/llvm-cov/Inputs/prefer_used_to_unused.covmapping and b/test/tools/llvm-cov/Inputs/prefer_used_to_unused.covmapping differ diff --git a/test/tools/llvm-cov/Inputs/regionMarkers.covmapping b/test/tools/llvm-cov/Inputs/regionMarkers.covmapping index 1c9b5dd45c7..af920c2d169 100644 Binary files a/test/tools/llvm-cov/Inputs/regionMarkers.covmapping and b/test/tools/llvm-cov/Inputs/regionMarkers.covmapping 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 Binary files a/test/tools/llvm-cov/Inputs/report.covmapping and b/test/tools/llvm-cov/Inputs/report.covmapping differ diff --git a/test/tools/llvm-cov/Inputs/templateInstantiations.covmapping b/test/tools/llvm-cov/Inputs/templateInstantiations.covmapping index 2dfc6cddbe7..b604e0604ad 100644 Binary files a/test/tools/llvm-cov/Inputs/templateInstantiations.covmapping and b/test/tools/llvm-cov/Inputs/templateInstantiations.covmapping 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: INDEX: 41.67% (5/12) INDEX: -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 // ALL: [[@LINE]]| |template 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|} + + // 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|} // 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: {{^ *}}| _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: [[@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(0); // ALL-NEXT: [[@LINE]]| 1| func(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:
[[@LINE-44]]
// before
-// HTML-FILTER-NOT: 
[[@LINE-45]]
// before
-// HTML-ALL: 
[[@LINE-44]]
template<typename T>
-// HTML-ALL: 
[[@LINE-44]]
2
int func(T x) {
-// HTML-ALL: 
[[@LINE-44]]
2
  if(x)
-// HTML-ALL: 
[[@LINE-44]]
1
    ret
-// HTML-ALL: 
[[@LINE-44]]
2
  else
-// HTML-ALL: 
[[@LINE-44]]
1
    ret
-// HTML-ALL: 
[[@LINE-44]]
0
-// HTML-ALL: 
[[@LINE-44]]
2
}
-
-// HTML-SHARED: 
_Z4funcIbEiT_
-// HTML-SHARED:
[[@LINE-53]]
1
int func(T x) {
-// HTML-SHARED: 
[[@LINE-53]]
1
  if(x)
-// HTML-SHARED: 
[[@LINE-53]]
1
    ret
-// HTML-SHARED: 
[[@LINE-53]]
1
  else
-// HTML-SHARED: 
[[@LINE-53]]
0
-// HTML-SHARED: 
[[@LINE-53]]
0
-// HTML-SHARED: 
[[@LINE-53]]
1
}
+// HTML-ALL: 
4
// before
+// HTML-FILTER-NOT: 
4
// before
+// HTML-ALL: 
6
template<typename T>
 
 // HTML-ALL: 
_Z4funcIiEiT_
// HTML-FILTER-NOT:
_Z4funcIiEiT_
-// HTML-ALL:
[[@LINE-63]]
1
int func(T x) {
-// HTML-ALL: 
[[@LINE-63]]
1
  if(x)
-// HTML-ALL: 
[[@LINE-63]]
0
-// HTML-ALL: 
[[@LINE-63]]
1
  else
-// HTML-ALL: 
[[@LINE-63]]
1
    ret
-// HTML-ALL: 
[[@LINE-63]]
0
-// HTML-ALL: 
[[@LINE-63]]
1
}
+// HTML-ALL: 
7
1
int func(T x) {
 
-// HTML-ALL: 
[[@LINE-44]]
1
int main() {
-// HTML-ALL: 
[[@LINE-44]]
1
  func<int>(0);
-// HTML-ALL: 
[[@LINE-44]]
1
  func<bool>(true);
-// HTML-ALL: 
[[@LINE-44]]
1
  return 0;
-// HTML-ALL: 
[[@LINE-44]]
1
}
-
-// HTML-ALL: 
[[@LINE-45]]
// after
-// HTML-FILTER-NOT: 
[[@LINE-46]]
// after
+// HTML-SHARED: 
_Z4funcIbEiT_
+// HTML-SHARED:
7
1
int func(T x) {
 
 // RUN: FileCheck -check-prefix=HTML-JUMP -input-file=%t.html.dir/coverage/tmp/showTemplateInstantiations.cpp.html %s
 // HTML-JUMP: 
Source (jump to first uncovered line)
@@ -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, 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; }