aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWentao Zhang <35722712+whentojump@users.noreply.github.com>2024-06-19 15:41:55 -0500
committerGitHub <noreply@github.com>2024-06-19 15:41:55 -0500
commit61e62ce2ebde23937af3e4ca2d84195bb00dbe05 (patch)
tree9576c2ad646c20761407fddadef86ad4c69415a8
parent0a5292ebbb393b70dbb46b0a30a64a3b3a2463e1 (diff)
downloadllvm-61e62ce2ebde23937af3e4ca2d84195bb00dbe05.zip
llvm-61e62ce2ebde23937af3e4ca2d84195bb00dbe05.tar.gz
llvm-61e62ce2ebde23937af3e4ca2d84195bb00dbe05.tar.bz2
[llvm-cov] let text mode divider honor --show-branch-summary, --show-region-summary etc (#96016)
-rw-r--r--llvm/tools/llvm-cov/CoverageReport.cpp29
1 files changed, 23 insertions, 6 deletions
diff --git a/llvm/tools/llvm-cov/CoverageReport.cpp b/llvm/tools/llvm-cov/CoverageReport.cpp
index 49a35f2..00aea40 100644
--- a/llvm/tools/llvm-cov/CoverageReport.cpp
+++ b/llvm/tools/llvm-cov/CoverageReport.cpp
@@ -102,8 +102,25 @@ 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) {
- size_t Length = std::accumulate(ColumnWidths.begin(), ColumnWidths.end(), 0);
+void renderDivider(raw_ostream &OS, const CoverageViewOptions &Options, bool isFileReport) {
+ size_t Length;
+ if (isFileReport) {
+ Length = std::accumulate(std::begin(FileReportColumns), std::end(FileReportColumns), 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]);
+ } else {
+ Length = std::accumulate(std::begin(FunctionReportColumns), std::end(FunctionReportColumns), 0);
+ if (!Options.ShowBranchSummary)
+ Length -= (FunctionReportColumns[7] + FunctionReportColumns[8] + FunctionReportColumns[9]);
+ if (!Options.ShowMCDCSummary)
+ Length -= (FunctionReportColumns[10] + FunctionReportColumns[11] + FunctionReportColumns[12]);
+ }
for (size_t I = 0; I < Length; ++I)
OS << '-';
}
@@ -405,7 +422,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(OS, Options, false);
OS << "\n";
FunctionCoverageSummary Totals("TOTAL");
for (const auto &F : Functions) {
@@ -418,7 +435,7 @@ void CoverageReport::renderFunctionReports(ArrayRef<std::string> Files,
render(Function, DC, OS);
}
if (Totals.ExecutionCount) {
- renderDivider(FunctionReportColumns, OS);
+ renderDivider(OS, Options, false);
OS << "\n";
render(Totals, DC, OS);
}
@@ -544,7 +561,7 @@ void CoverageReport::renderFileReports(
Column::RightAlignment)
<< column("Cover", FileReportColumns[18], Column::RightAlignment);
OS << "\n";
- renderDivider(FileReportColumns, OS);
+ renderDivider(OS, Options, true);
OS << "\n";
std::vector<const FileCoverageSummary *> EmptyFiles;
@@ -563,7 +580,7 @@ void CoverageReport::renderFileReports(
render(*FCS, OS);
}
- renderDivider(FileReportColumns, OS);
+ renderDivider(OS, Options, true);
OS << "\n";
render(Totals, OS);
}