Skip to content

Commit 06aa078

Browse files
authored
[llvm-cov] Coverage report HTML UI to jump between uncovered parts of code (#95662)
I replaced "jump to first uncovered line" with UI buttons and keyboard shortcut to jump between uncovered parts of code: lines (key L), branchs (key B), regions (key R). User can also jump in reverse direction with shift+key.
1 parent c22d391 commit 06aa078

10 files changed

+223
-43
lines changed

llvm/docs/ReleaseNotes.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,12 @@ Changes to the LLVM tools
292292
now has a map for the mapped files. (`#92835
293293
<https://github.com/llvm/llvm-project/pull/92835>`).
294294

295+
* llvm-cov now generates HTML report with JavaScript code to allow simple
296+
jumping between uncovered parts (lines/regions/branches) of code
297+
using buttons on top-right corner of the page or using keys (L/R/B or
298+
jumping in reverse direction with shift+L/R/B). (`#95662
299+
<https://github.com/llvm/llvm-project/pull/95662>`).
300+
295301
Changes to LLDB
296302
---------------------------------
297303

llvm/test/tools/llvm-cov/Inputs/showProjectSummary.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ HTML-FILE: <pre>{{.*}}showProjectSummary.cpp</pre>
1111
HTML-FUNCTION: <pre>main</pre>
1212
HTML-HEADER: <td><pre>Line</pre></td>
1313
HTML-HEADER: <td><pre>Count</pre></td>
14-
HTML-HEADER: <td><pre>Source (<a href='#L8'>jump to first uncovered line</a>)</pre></td>
14+
HTML-HEADER: <td><pre>Source</pre></td>
1515
HTML-FOOTER: <h5>Generated by llvm-cov{{.*}}</h5>

llvm/test/tools/llvm-cov/showLineExecutionCounts.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ int main() { // TEXT: [[@LINE]]| 161|int main(
4444
// RUN: FileCheck -check-prefixes=HTML,HTML-WHOLE-FILE -input-file %t.html.dir/coverage/tmp/showLineExecutionCounts.cpp.html %s
4545
// RUN: FileCheck -check-prefixes=HTML,HTML-FILTER -input-file %t.html.filtered.dir/coverage/tmp/showLineExecutionCounts.cpp.html %s
4646
//
47-
// HTML-WHOLE-FILE: <td class='line-number'><a name='L4' href='#L4'><pre>4</pre></a></td><td class='uncovered-line'></td><td class='code'><pre>// before
48-
// 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
47+
// HTML-WHOLE-FILE: <td class='line-number'><a name='L4' href='#L4'><pre>4</pre></a></td><td class='skipped-line'></td><td class='code'><pre>// before
48+
// HTML-FILTER-NOT: <td class='line-number'><a name='L4' href='#L4'><pre>4</pre></a></td><td class='skipped-line'></td><td class='code'><pre>// before
4949
// HTML: <td class='line-number'><a name='L6' href='#L6'><pre>6</pre></a></td><td class='covered-line'><pre>161</pre></td><td class='code'><pre>int main() {
50-
// HTML-WHOLE-FILE: <td class='line-number'><a name='L26' href='#L26'><pre>26</pre></a></td><td class='uncovered-line'></td><td class='code'><pre>// after
51-
// HTML-FILTER-NOT: <td class='line-number'><a name='L26' href='#L26'><pre>26</pre></a></td><td class='uncovered-line'></td><td class='code'><pre>// after
50+
// HTML-WHOLE-FILE: <td class='line-number'><a name='L26' href='#L26'><pre>26</pre></a></td><td class='skipped-line'></td><td class='code'><pre>// after
51+
// HTML-FILTER-NOT: <td class='line-number'><a name='L26' href='#L26'><pre>26</pre></a></td><td class='skipped-line'></td><td class='code'><pre>// after
5252
//
5353
// Test index creation.
5454
// RUN: FileCheck -check-prefix=TEXT-INDEX -input-file %t.dir/index.txt %s

llvm/test/tools/llvm-cov/showTemplateInstantiations.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ int main() { // ALL: [[@LINE]]| 1|int main() {
4545
// RUN: FileCheck -check-prefixes=HTML-SHARED,HTML-ALL -input-file=%t.html.dir/coverage/tmp/showTemplateInstantiations.cpp.html %s
4646
// RUN: FileCheck -check-prefixes=HTML-SHARED,HTML-FILTER -input-file=%t.html.filtered.dir/coverage/tmp/showTemplateInstantiations.cpp.html %s
4747

48-
// 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
49-
// 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
50-
// 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;
48+
// HTML-ALL: <td class='line-number'><a name='L4' href='#L4'><pre>4</pre></a></td><td class='skipped-line'></td><td class='code'><pre>// before
49+
// HTML-FILTER-NOT: <td class='line-number'><a name='L4' href='#L4'><pre>4</pre></a></td><td class='skipped-line'></td><td class='code'><pre>// before
50+
// HTML-ALL: <td class='line-number'><a name='L6' href='#L6'><pre>6</pre></a></td><td class='skipped-line'></td><td class='code'><pre>template&lt;typename T&gt;
5151

5252
// HTML-ALL: <div class='source-name-title'><pre>_Z4funcIiEiT_</pre></div>
5353
// HTML-FILTER-NOT: <div class='source-name-title'><pre>_Z4funcIiEiT_</pre></div><table>
@@ -57,8 +57,12 @@ int main() { // ALL: [[@LINE]]| 1|int main() {
5757
// 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) {
5858

5959
// RUN: FileCheck -check-prefix=HTML-JUMP -input-file=%t.html.dir/coverage/tmp/showTemplateInstantiations.cpp.html %s
60-
// HTML-JUMP: <pre>Source (<a href='#L{{[0-9]+}}'>jump to first uncovered line</a>)</pre>
61-
// HTML-JUMP-NOT: <pre>Source (<a href='#L{{[0-9]+}}'>jump to first uncovered line</a>)</pre>
60+
// HTML-JUMP: <a href='javascript:next_line()'>next uncovered line (L)</a>
61+
// HTML-JUMP-NOT: <a href='javascript:next_line()'>next uncovered line (L)</a>
62+
// HTML-JUMP: <a href='javascript:next_region()'>next uncovered region (R)</a>
63+
// HTML-JUMP-NOT: <a href='javascript:next_region()'>next uncovered region (R)</a>
64+
// HTML-JUMP: <a href='javascript:next_branch()'>next uncovered branch (B)</a>
65+
// HTML-JUMP-NOT: <a href='javascript:next_branch()'>next uncovered branch (B)</a>
6266

6367
// RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %S/Inputs/templateInstantiations.profdata -show-instantiations=false -path-equivalence=/tmp,%S %s | FileCheck -check-prefix=NO_INSTS %s
6468
// NO_INSTS-NOT: {{^ *}}| _Z4funcIbEiT_:

llvm/tools/llvm-cov/SourceCoverageView.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,7 @@ void SourceCoverageView::print(raw_ostream &OS, bool WholeFile,
203203
if (ShowSourceName)
204204
renderSourceName(OS, WholeFile);
205205

206-
renderTableHeader(OS, (ViewDepth > 0) ? 0 : getFirstUncoveredLineNo(),
207-
ViewDepth);
206+
renderTableHeader(OS, ViewDepth);
208207

209208
// We need the expansions, instantiations, and branches sorted so we can go
210209
// through them while we iterate lines.

llvm/tools/llvm-cov/SourceCoverageView.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,7 @@ class SourceCoverageView {
262262
virtual void renderTitle(raw_ostream &OS, StringRef CellText) = 0;
263263

264264
/// Render the table header for a given source file.
265-
virtual void renderTableHeader(raw_ostream &OS, unsigned FirstUncoveredLineNo,
266-
unsigned IndentLevel) = 0;
265+
virtual void renderTableHeader(raw_ostream &OS, unsigned IndentLevel) = 0;
267266

268267
/// @}
269268

0 commit comments

Comments
 (0)