Skip to content

[llvm-cov] Coverage report HTML UI to jump between uncovered parts of code #95662

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions llvm/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,12 @@ Changes to the LLVM tools
now has a map for the mapped files. (`#92835
<https://github.com/llvm/llvm-project/pull/92835>`).

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

Changes to LLDB
---------------------------------

Expand Down
2 changes: 1 addition & 1 deletion llvm/test/tools/llvm-cov/Inputs/showProjectSummary.test
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ HTML-FILE: <pre>{{.*}}showProjectSummary.cpp</pre>
HTML-FUNCTION: <pre>main</pre>
HTML-HEADER: <td><pre>Line</pre></td>
HTML-HEADER: <td><pre>Count</pre></td>
HTML-HEADER: <td><pre>Source (<a href='#L8'>jump to first uncovered line</a>)</pre></td>
HTML-HEADER: <td><pre>Source</pre></td>
HTML-FOOTER: <h5>Generated by llvm-cov{{.*}}</h5>
8 changes: 4 additions & 4 deletions llvm/test/tools/llvm-cov/showLineExecutionCounts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ int main() { // TEXT: [[@LINE]]| 161|int main(
// RUN: FileCheck -check-prefixes=HTML,HTML-WHOLE-FILE -input-file %t.html.dir/coverage/tmp/showLineExecutionCounts.cpp.html %s
// RUN: FileCheck -check-prefixes=HTML,HTML-FILTER -input-file %t.html.filtered.dir/coverage/tmp/showLineExecutionCounts.cpp.html %s
//
// 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
// 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-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
// 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
// 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() {
// 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
// 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
// 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
// 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
//
// Test index creation.
// RUN: FileCheck -check-prefix=TEXT-INDEX -input-file %t.dir/index.txt %s
Expand Down
14 changes: 9 additions & 5 deletions llvm/test/tools/llvm-cov/showTemplateInstantiations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ 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='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: <td class='line-number'><a name='L4' href='#L4'><pre>4</pre></a></td><td class='skipped-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='skipped-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='skipped-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>
Expand All @@ -57,8 +57,12 @@ int main() { // ALL: [[@LINE]]| 1|int main() {
// 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>
// HTML-JUMP-NOT: <pre>Source (<a href='#L{{[0-9]+}}'>jump to first uncovered line</a>)</pre>
// HTML-JUMP: <a href='javascript:next_line()'>next uncovered line (L)</a>
// HTML-JUMP-NOT: <a href='javascript:next_line()'>next uncovered line (L)</a>
// HTML-JUMP: <a href='javascript:next_region()'>next uncovered region (R)</a>
// HTML-JUMP-NOT: <a href='javascript:next_region()'>next uncovered region (R)</a>
// HTML-JUMP: <a href='javascript:next_branch()'>next uncovered branch (B)</a>
// HTML-JUMP-NOT: <a href='javascript:next_branch()'>next uncovered branch (B)</a>

// 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
// NO_INSTS-NOT: {{^ *}}| _Z4funcIbEiT_:
Expand Down
3 changes: 1 addition & 2 deletions llvm/tools/llvm-cov/SourceCoverageView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,7 @@ void SourceCoverageView::print(raw_ostream &OS, bool WholeFile,
if (ShowSourceName)
renderSourceName(OS, WholeFile);

renderTableHeader(OS, (ViewDepth > 0) ? 0 : getFirstUncoveredLineNo(),
ViewDepth);
renderTableHeader(OS, ViewDepth);

// We need the expansions, instantiations, and branches sorted so we can go
// through them while we iterate lines.
Expand Down
3 changes: 1 addition & 2 deletions llvm/tools/llvm-cov/SourceCoverageView.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,7 @@ class SourceCoverageView {
virtual void renderTitle(raw_ostream &OS, StringRef CellText) = 0;

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

/// @}

Expand Down
Loading
Loading