[llvm] [llvm-cov] Make table header in index.html sticky (PR #203315)
Hendrik Müller via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 11 08:47:25 PDT 2026
https://github.com/henne90gen created https://github.com/llvm/llvm-project/pull/203315
This change ensures that the table header is always visible in the HTML coverage reports index page.
If the report has many sources files, having to scroll to the top of the page to see which column contains which numbers is quite annoying.
<img width="1302" height="244" alt="image" src="https://github.com/user-attachments/assets/09151841-d3cf-4849-9acb-269dc1144e93" />
<img width="1302" height="244" alt="image" src="https://github.com/user-attachments/assets/e0d6c78e-d561-4a6c-90c2-da233a44800f" />
>From 07bbf858f8e22008e43b71a9f3b455771b7a1910 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hendrik=20M=C3=BCller?= <hendrik.mueller at fabmatics.com>
Date: Thu, 11 Jun 2026 17:35:15 +0200
Subject: [PATCH] [llvm-cov] Make table header in index.html sticky
---
.../tools/llvm-cov/SourceCoverageViewHTML.cpp | 28 +++++++++++++------
1 file changed, 20 insertions(+), 8 deletions(-)
diff --git a/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp b/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
index 5c31fe5ab1b0f..822abc32463b7 100644
--- a/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
+++ b/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
@@ -249,6 +249,12 @@ table {
font-weight: bold;
text-align: left;
}
+.column-entry-sticky {
+ position: sticky;
+ top: 0;
+ z-index: 1;
+ background-color: Canvas;
+}
.column-entry-yellow {
text-align: left;
background-color: #ff06;
@@ -551,18 +557,24 @@ void CoveragePrinterHTML::closeViewFile(OwnedStream OS) {
static void emitColumnLabelsForIndex(raw_ostream &OS,
const CoverageViewOptions &Opts) {
SmallVector<std::string, 4> Columns;
- Columns.emplace_back(tag("td", "Filename", "column-entry-bold"));
- Columns.emplace_back(tag("td", "Function Coverage", "column-entry-bold"));
+ Columns.emplace_back(
+ tag("td", "Filename", "column-entry-bold column-entry-sticky"));
+ Columns.emplace_back(
+ tag("td", "Function Coverage", "column-entry-bold column-entry-sticky"));
if (Opts.ShowInstantiationSummary)
- Columns.emplace_back(
- tag("td", "Instantiation Coverage", "column-entry-bold"));
- Columns.emplace_back(tag("td", "Line Coverage", "column-entry-bold"));
+ Columns.emplace_back(tag("td", "Instantiation Coverage",
+ "column-entry-bold column-entry-sticky"));
+ Columns.emplace_back(
+ tag("td", "Line Coverage", "column-entry-bold column-entry-sticky"));
if (Opts.ShowRegionSummary)
- Columns.emplace_back(tag("td", "Region Coverage", "column-entry-bold"));
+ Columns.emplace_back(
+ tag("td", "Region Coverage", "column-entry-bold column-entry-sticky"));
if (Opts.ShowBranchSummary)
- Columns.emplace_back(tag("td", "Branch Coverage", "column-entry-bold"));
+ Columns.emplace_back(
+ tag("td", "Branch Coverage", "column-entry-bold column-entry-sticky"));
if (Opts.ShowMCDCSummary)
- Columns.emplace_back(tag("td", "MC/DC", "column-entry-bold"));
+ Columns.emplace_back(
+ tag("td", "MC/DC", "column-entry-bold column-entry-sticky"));
OS << tag("tr", join(Columns.begin(), Columns.end(), ""));
}
More information about the llvm-commits
mailing list