[llvm-branch-commits] [llvm] Backport 0bf4f82 to release/18.x (PR #82571)
Wentao Zhang via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Feb 21 19:13:25 PST 2024
https://github.com/whentojump created https://github.com/llvm/llvm-project/pull/82571
Manually cherry-pick 0bf4f82 and resolve conflicts
Closes #82570
>From 37f5e39e1c54ad1c839d80580b9e5303b6e692d3 Mon Sep 17 00:00:00 2001
From: Wentao Zhang <35722712+whentojump at users.noreply.github.com>
Date: Fri, 16 Feb 2024 23:24:31 -0600
Subject: [PATCH] [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
(cherry picked from commit 0bf4f82f661817c79bd538c82c99515837cf1cf8)
---
llvm/test/tools/llvm-cov/mcdc-general-none.test | 2 +-
llvm/test/tools/llvm-cov/mcdc-general.test | 2 +-
llvm/tools/llvm-cov/SourceCoverageView.cpp | 2 +-
llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp | 9 +++++----
llvm/tools/llvm-cov/SourceCoverageViewText.cpp | 3 ++-
5 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/llvm/test/tools/llvm-cov/mcdc-general-none.test b/llvm/test/tools/llvm-cov/mcdc-general-none.test
index bcf8f3cbd05d45e..a373075cc5e37cc 100644
--- a/llvm/test/tools/llvm-cov/mcdc-general-none.test
+++ b/llvm/test/tools/llvm-cov/mcdc-general-none.test
@@ -52,7 +52,7 @@
// Test html output.
// RUN: llvm-cov show --show-mcdc-summary --show-mcdc %S/Inputs/mcdc-general.o -instr-profile %t.profdata -path-equivalence=/tmp,%S/Inputs %S/Inputs/mcdc-general.cpp -format html -o %t.html.dir
// RUN: FileCheck -check-prefix=HTML -input-file=%t.html.dir/coverage/tmp/mcdc-general.cpp.html %s
-// HTML-COUNT-4: MC/DC Decision Region (<span class='line-number'><a name='L{{[0-9]+}}' href='#L{{[0-9]+}}'><span>
+// HTML-COUNT-4: MC/DC Decision Region (<span class='line-number'><a href='#L{{[0-9]+}}'><span>
// RUN: FileCheck -check-prefix HTML-INDEX -input-file %t.html.dir/index.html %s
// HTML-INDEX-LABEL: <table>
diff --git a/llvm/test/tools/llvm-cov/mcdc-general.test b/llvm/test/tools/llvm-cov/mcdc-general.test
index 588aed09c16a5e3..ded2f3eb1c9a5d3 100644
--- a/llvm/test/tools/llvm-cov/mcdc-general.test
+++ b/llvm/test/tools/llvm-cov/mcdc-general.test
@@ -118,7 +118,7 @@
// Test html output.
// RUN: llvm-cov show --show-mcdc-summary --show-mcdc %S/Inputs/mcdc-general.o -instr-profile %t.profdata -path-equivalence=/tmp,%S/Inputs %S/Inputs/mcdc-general.cpp -format html -o %t.html.dir
// RUN: FileCheck -check-prefix=HTML -input-file=%t.html.dir/coverage/tmp/mcdc-general.cpp.html %s
-// HTML-COUNT-4: MC/DC Decision Region (<span class='line-number'><a name='L{{[0-9]+}}' href='#L{{[0-9]+}}'><span>
+// HTML-COUNT-4: MC/DC Decision Region (<span class='line-number'><a href='#L{{[0-9]+}}'><span>
// RUN: FileCheck -check-prefix HTML-INDEX -input-file %t.html.dir/index.html %s
// HTML-INDEX-LABEL: <table>
diff --git a/llvm/tools/llvm-cov/SourceCoverageView.cpp b/llvm/tools/llvm-cov/SourceCoverageView.cpp
index 71edd5fec4280a6..5b85d7d86bfb946 100644
--- a/llvm/tools/llvm-cov/SourceCoverageView.cpp
+++ b/llvm/tools/llvm-cov/SourceCoverageView.cpp
@@ -139,7 +139,7 @@ bool SourceCoverageView::shouldRenderRegionMarkers(
bool SourceCoverageView::hasSubViews() const {
return !ExpansionSubViews.empty() || !InstantiationSubViews.empty() ||
- !BranchSubViews.empty();
+ !BranchSubViews.empty() || !MCDCSubViews.empty();
}
std::unique_ptr<SourceCoverageView>
diff --git a/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp b/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
index abc4c49ecae98e3..b93d8cb035306b7 100644
--- a/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
+++ b/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
@@ -246,6 +246,9 @@ tr:hover {
tr:last-child {
border-bottom: none;
}
+tr:has(> td >a:target) > td.code > pre {
+ background-color: #ffa;
+}
)";
const char *EndHeader = "</head>";
@@ -990,15 +993,13 @@ void SourceCoverageViewHTML::renderMCDCView(raw_ostream &OS, MCDCView &MRV,
std::string ColNoStr = Twine(DecisionRegion.ColumnStart).str();
std::string TargetName = "L" + LineNoStr;
OS << tag("span",
- a("#" + TargetName, tag("span", LineNoStr + ":" + ColNoStr),
- TargetName),
+ a("#" + TargetName, tag("span", LineNoStr + ":" + ColNoStr)),
"line-number") +
") to (";
LineNoStr = utostr(uint64_t(DecisionRegion.LineEnd));
ColNoStr = utostr(uint64_t(DecisionRegion.ColumnEnd));
OS << tag("span",
- a("#" + TargetName, tag("span", LineNoStr + ":" + ColNoStr),
- TargetName),
+ a("#" + TargetName, tag("span", LineNoStr + ":" + ColNoStr)),
"line-number") +
")\n\n";
diff --git a/llvm/tools/llvm-cov/SourceCoverageViewText.cpp b/llvm/tools/llvm-cov/SourceCoverageViewText.cpp
index 73b7ffe16a9637e..580da45ecfc0d83 100644
--- a/llvm/tools/llvm-cov/SourceCoverageViewText.cpp
+++ b/llvm/tools/llvm-cov/SourceCoverageViewText.cpp
@@ -382,7 +382,8 @@ void SourceCoverageViewText::renderMCDCView(raw_ostream &OS, MCDCView &MRV,
colored_ostream(OS, raw_ostream::RED,
getOptions().Colors && Record.getPercentCovered() < 100.0,
/*Bold=*/false, /*BG=*/true)
- << format("%0.2f", Record.getPercentCovered()) << "%\n";
+ << format("%0.2f", Record.getPercentCovered()) << "%";
+ OS << "\n";
renderLinePrefix(OS, ViewDepth);
OS << "\n";
}
More information about the llvm-branch-commits
mailing list