[llvm] [llvm-cov] let text mode divider honor `--show-branch-summary` `--show-region-summary` etc (PR #96016)
Wentao Zhang via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 18 19:55:53 PDT 2024
https://github.com/whentojump created https://github.com/llvm/llvm-project/pull/96016
Otherwise it would be unnecessarily too long
Before
![before](https://github.com/llvm/llvm-project/assets/35722712/9bff2b98-eaee-4c09-8802-b3fb92508454)
After
![after](https://github.com/llvm/llvm-project/assets/35722712/bf89f236-f83b-414c-9a2a-a4f8d1559e56)
>From 4862716fd4d84ca0fe1229d30e549ec7092ec248 Mon Sep 17 00:00:00 2001
From: Wentao Zhang <zhangwt1997 at gmail.com>
Date: Tue, 18 Jun 2024 21:32:13 -0500
Subject: [PATCH] [llvm-cov] let text mode divider honor --show-branch-summary
--show-region-summary etc
---
llvm/tools/llvm-cov/CoverageReport.cpp | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/llvm/tools/llvm-cov/CoverageReport.cpp b/llvm/tools/llvm-cov/CoverageReport.cpp
index 49a35f2a943e6..463460b0553f8 100644
--- a/llvm/tools/llvm-cov/CoverageReport.cpp
+++ b/llvm/tools/llvm-cov/CoverageReport.cpp
@@ -102,8 +102,16 @@ void adjustColumnWidths(ArrayRef<StringRef> Files,
/// Prints a horizontal divider long enough to cover the given column
/// widths.
-void renderDivider(ArrayRef<size_t> ColumnWidths, raw_ostream &OS) {
+void renderDivider(ArrayRef<size_t> ColumnWidths, raw_ostream &OS, const CoverageViewOptions &Options) {
size_t Length = std::accumulate(ColumnWidths.begin(), ColumnWidths.end(), 0);
+ if (!Options.ShowRegionSummary)
+ Length -= (FileReportColumns[1] + FileReportColumns[2] + FileReportColumns[3]);
+ if (!Options.ShowInstantiationSummary)
+ Length -= (FileReportColumns[7] + FileReportColumns[8] + FileReportColumns[9]);
+ if (!Options.ShowBranchSummary)
+ Length -= (FileReportColumns[13] + FileReportColumns[14] + FileReportColumns[15]);
+ if (!Options.ShowMCDCSummary)
+ Length -= (FileReportColumns[16] + FileReportColumns[17] + FileReportColumns[18]);
for (size_t I = 0; I < Length; ++I)
OS << '-';
}
@@ -405,7 +413,7 @@ void CoverageReport::renderFunctionReports(ArrayRef<std::string> Files,
<< column("Miss", FunctionReportColumns[11], Column::RightAlignment)
<< column("Cover", FunctionReportColumns[12], Column::RightAlignment);
OS << "\n";
- renderDivider(FunctionReportColumns, OS);
+ renderDivider(FunctionReportColumns, OS, Options);
OS << "\n";
FunctionCoverageSummary Totals("TOTAL");
for (const auto &F : Functions) {
@@ -418,7 +426,7 @@ void CoverageReport::renderFunctionReports(ArrayRef<std::string> Files,
render(Function, DC, OS);
}
if (Totals.ExecutionCount) {
- renderDivider(FunctionReportColumns, OS);
+ renderDivider(FunctionReportColumns, OS, Options);
OS << "\n";
render(Totals, DC, OS);
}
@@ -544,7 +552,7 @@ void CoverageReport::renderFileReports(
Column::RightAlignment)
<< column("Cover", FileReportColumns[18], Column::RightAlignment);
OS << "\n";
- renderDivider(FileReportColumns, OS);
+ renderDivider(FileReportColumns, OS, Options);
OS << "\n";
std::vector<const FileCoverageSummary *> EmptyFiles;
@@ -563,7 +571,7 @@ void CoverageReport::renderFileReports(
render(*FCS, OS);
}
- renderDivider(FileReportColumns, OS);
+ renderDivider(FileReportColumns, OS, Options);
OS << "\n";
render(Totals, OS);
}
More information about the llvm-commits
mailing list