[Coverage] Use the wrapped segment when a line has entry segments
authorVedant Kumar <vsk@apple.com>
Thu, 9 Nov 2017 02:33:43 +0000 (02:33 +0000)
committerVedant Kumar <vsk@apple.com>
Thu, 9 Nov 2017 02:33:43 +0000 (02:33 +0000)
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.

llvm-svn: 317761

21 files changed:
llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
llvm/test/tools/llvm-cov/Inputs/deferred-regions.covmapping
llvm/test/tools/llvm-cov/Inputs/highlightedRanges.covmapping
llvm/test/tools/llvm-cov/Inputs/highlightedRanges.json
llvm/test/tools/llvm-cov/Inputs/instrprof-comdat.h
llvm/test/tools/llvm-cov/Inputs/lineExecutionCounts.covmapping
llvm/test/tools/llvm-cov/Inputs/prefer_used_to_unused.covmapping
llvm/test/tools/llvm-cov/Inputs/regionMarkers.covmapping
llvm/test/tools/llvm-cov/Inputs/regionMarkers.json
llvm/test/tools/llvm-cov/Inputs/report.covmapping
llvm/test/tools/llvm-cov/Inputs/templateInstantiations.covmapping
llvm/test/tools/llvm-cov/deferred-region.cpp
llvm/test/tools/llvm-cov/hideUnexecutedSubviews.test
llvm/test/tools/llvm-cov/load-multiple-objects.test
llvm/test/tools/llvm-cov/prefer_used_to_unused.h
llvm/test/tools/llvm-cov/report.cpp
llvm/test/tools/llvm-cov/showHighlightedRanges.cpp
llvm/test/tools/llvm-cov/showTemplateInstantiations.cpp
llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
llvm/tools/llvm-cov/SourceCoverageViewText.cpp
llvm/unittests/ProfileData/CoverageMappingTest.cpp

index ce93229..6cde386 100644 (file)
@@ -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);
index d16db88..6d7919e 100644 (file)
Binary files a/llvm/test/tools/llvm-cov/Inputs/deferred-regions.covmapping and b/llvm/test/tools/llvm-cov/Inputs/deferred-regions.covmapping differ
index 5c1b1d6..5c3d67f 100644 (file)
Binary files a/llvm/test/tools/llvm-cov/Inputs/highlightedRanges.covmapping and b/llvm/test/tools/llvm-cov/Inputs/highlightedRanges.covmapping differ
index 2948e86..cff6ab3 100644 (file)
@@ -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: ],
 
 // 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}}}
index 5a6d72b..07941f9 100644 (file)
@@ -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.
index f70ea05..0b2458a 100644 (file)
Binary files a/llvm/test/tools/llvm-cov/Inputs/lineExecutionCounts.covmapping and b/llvm/test/tools/llvm-cov/Inputs/lineExecutionCounts.covmapping differ
index 4722129..134067e 100644 (file)
Binary files a/llvm/test/tools/llvm-cov/Inputs/prefer_used_to_unused.covmapping and b/llvm/test/tools/llvm-cov/Inputs/prefer_used_to_unused.covmapping differ
index 1c9b5dd..af920c2 100644 (file)
Binary files a/llvm/test/tools/llvm-cov/Inputs/regionMarkers.covmapping and b/llvm/test/tools/llvm-cov/Inputs/regionMarkers.covmapping differ
index 0589f7b..c996433 100644 (file)
@@ -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: ],
 
 // 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}}
index 5d0bfc1..f9858ed 100644 (file)
Binary files a/llvm/test/tools/llvm-cov/Inputs/report.covmapping and b/llvm/test/tools/llvm-cov/Inputs/report.covmapping differ
index 2dfc6cd..b604e06 100644 (file)
Binary files a/llvm/test/tools/llvm-cov/Inputs/templateInstantiations.covmapping and b/llvm/test/tools/llvm-cov/Inputs/templateInstantiations.covmapping differ
index 09d9d09..a3f6b01 100644 (file)
@@ -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
index 20f0a43..e972a19 100644 (file)
@@ -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)
index 55fed31..41eae19 100644 (file)
@@ -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
index 852eb92..4d5e18c 100644 (file)
@@ -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) {
index be7b5ea..6676ed8 100644 (file)
@@ -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
index bfcdf76..f225816 100644 (file)
@@ -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
index 428ceac..380e98b 100644 (file)
@@ -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
index e839184..7e9fc23 100644 (file)
@@ -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;
 
index 4b69b08..2480ee9 100644 (file)
@@ -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;
   }
index ce52c6f..7c94ece 100644 (file)
@@ -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;
   }