Skip to content

Commit 0bf4f82

Browse files
authored
[llvm-cov][CoverageView] minor fix/improvement to HTML and text coverage output (#80952)
1. add the missing condition for MC/DC in hasSubViews() 2. add style for selected line 3. remove name="Ln" attribute in the link within MC/DC views 4. remove color for \n
1 parent 80fcecb commit 0bf4f82

File tree

5 files changed

+10
-8
lines changed

5 files changed

+10
-8
lines changed

Diff for: llvm/test/tools/llvm-cov/mcdc-general-none.test

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
// RUN: rm -rf %t.html.dir
5454
// RUN: llvm-cov show --show-mcdc-summary --show-mcdc %S/Inputs/mcdc-general.o -instr-profile %t.profdata -path-equivalence=.,%S/Inputs -format html -o %t.html.dir
5555
// RUN: FileCheck -check-prefix=HTML -input-file=%t.html.dir/coverage/mcdc-general.cpp.html %s
56-
// HTML-COUNT-4: MC/DC Decision Region (<span class='line-number'><a name='L{{[0-9]+}}' href='#L{{[0-9]+}}'><span>
56+
// HTML-COUNT-4: MC/DC Decision Region (<span class='line-number'><a href='#L{{[0-9]+}}'><span>
5757

5858
// RUN: FileCheck -check-prefix HTML-INDEX -input-file %t.html.dir/index.html %s
5959
// HTML-INDEX-LABEL: <table>

Diff for: llvm/test/tools/llvm-cov/mcdc-general.test

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
// RUN: rm -rf %t.html.dir
120120
// RUN: llvm-cov show --show-mcdc-summary --show-mcdc %S/Inputs/mcdc-general.o -instr-profile %t.profdata -path-equivalence=.,%S/Inputs -format html -o %t.html.dir
121121
// RUN: FileCheck -check-prefix=HTML -input-file=%t.html.dir/coverage/mcdc-general.cpp.html %s
122-
// HTML-COUNT-4: MC/DC Decision Region (<span class='line-number'><a name='L{{[0-9]+}}' href='#L{{[0-9]+}}'><span>
122+
// HTML-COUNT-4: MC/DC Decision Region (<span class='line-number'><a href='#L{{[0-9]+}}'><span>
123123

124124
// RUN: FileCheck -check-prefix HTML-INDEX -input-file %t.html.dir/index.html %s
125125
// HTML-INDEX-LABEL: <table>

Diff for: llvm/tools/llvm-cov/SourceCoverageView.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ bool SourceCoverageView::shouldRenderRegionMarkers(
139139

140140
bool SourceCoverageView::hasSubViews() const {
141141
return !ExpansionSubViews.empty() || !InstantiationSubViews.empty() ||
142-
!BranchSubViews.empty();
142+
!BranchSubViews.empty() || !MCDCSubViews.empty();
143143
}
144144

145145
std::unique_ptr<SourceCoverageView>

Diff for: llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,9 @@ tr:hover {
246246
tr:last-child {
247247
border-bottom: none;
248248
}
249+
tr:has(> td >a:target) > td.code > pre {
250+
background-color: #ffa;
251+
}
249252
)";
250253

251254
const char *EndHeader = "</head>";
@@ -990,15 +993,13 @@ void SourceCoverageViewHTML::renderMCDCView(raw_ostream &OS, MCDCView &MRV,
990993
std::string ColNoStr = Twine(DecisionRegion.ColumnStart).str();
991994
std::string TargetName = "L" + LineNoStr;
992995
OS << tag("span",
993-
a("#" + TargetName, tag("span", LineNoStr + ":" + ColNoStr),
994-
TargetName),
996+
a("#" + TargetName, tag("span", LineNoStr + ":" + ColNoStr)),
995997
"line-number") +
996998
") to (";
997999
LineNoStr = utostr(uint64_t(DecisionRegion.LineEnd));
9981000
ColNoStr = utostr(uint64_t(DecisionRegion.ColumnEnd));
9991001
OS << tag("span",
1000-
a("#" + TargetName, tag("span", LineNoStr + ":" + ColNoStr),
1001-
TargetName),
1002+
a("#" + TargetName, tag("span", LineNoStr + ":" + ColNoStr)),
10021003
"line-number") +
10031004
")\n\n";
10041005

Diff for: llvm/tools/llvm-cov/SourceCoverageViewText.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,8 @@ void SourceCoverageViewText::renderMCDCView(raw_ostream &OS, MCDCView &MRV,
382382
colored_ostream(OS, raw_ostream::RED,
383383
getOptions().Colors && Record.getPercentCovered() < 100.0,
384384
/*Bold=*/false, /*BG=*/true)
385-
<< format("%0.2f", Record.getPercentCovered()) << "%\n";
385+
<< format("%0.2f", Record.getPercentCovered()) << "%";
386+
OS << "\n";
386387
renderLinePrefix(OS, ViewDepth);
387388
OS << "\n";
388389
}

0 commit comments

Comments
 (0)