Skip to content

Commit ed1bd3c

Browse files
whentojumpAlexisPerry
authored andcommitted
[llvm-cov] let text mode divider honor --show-branch-summary, --show-region-summary etc (llvm#96016)
1 parent c39df91 commit ed1bd3c

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

llvm/tools/llvm-cov/CoverageReport.cpp

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,25 @@ void adjustColumnWidths(ArrayRef<StringRef> Files,
102102

103103
/// Prints a horizontal divider long enough to cover the given column
104104
/// widths.
105-
void renderDivider(ArrayRef<size_t> ColumnWidths, raw_ostream &OS) {
106-
size_t Length = std::accumulate(ColumnWidths.begin(), ColumnWidths.end(), 0);
105+
void renderDivider(raw_ostream &OS, const CoverageViewOptions &Options, bool isFileReport) {
106+
size_t Length;
107+
if (isFileReport) {
108+
Length = std::accumulate(std::begin(FileReportColumns), std::end(FileReportColumns), 0);
109+
if (!Options.ShowRegionSummary)
110+
Length -= (FileReportColumns[1] + FileReportColumns[2] + FileReportColumns[3]);
111+
if (!Options.ShowInstantiationSummary)
112+
Length -= (FileReportColumns[7] + FileReportColumns[8] + FileReportColumns[9]);
113+
if (!Options.ShowBranchSummary)
114+
Length -= (FileReportColumns[13] + FileReportColumns[14] + FileReportColumns[15]);
115+
if (!Options.ShowMCDCSummary)
116+
Length -= (FileReportColumns[16] + FileReportColumns[17] + FileReportColumns[18]);
117+
} else {
118+
Length = std::accumulate(std::begin(FunctionReportColumns), std::end(FunctionReportColumns), 0);
119+
if (!Options.ShowBranchSummary)
120+
Length -= (FunctionReportColumns[7] + FunctionReportColumns[8] + FunctionReportColumns[9]);
121+
if (!Options.ShowMCDCSummary)
122+
Length -= (FunctionReportColumns[10] + FunctionReportColumns[11] + FunctionReportColumns[12]);
123+
}
107124
for (size_t I = 0; I < Length; ++I)
108125
OS << '-';
109126
}
@@ -405,7 +422,7 @@ void CoverageReport::renderFunctionReports(ArrayRef<std::string> Files,
405422
<< column("Miss", FunctionReportColumns[11], Column::RightAlignment)
406423
<< column("Cover", FunctionReportColumns[12], Column::RightAlignment);
407424
OS << "\n";
408-
renderDivider(FunctionReportColumns, OS);
425+
renderDivider(OS, Options, false);
409426
OS << "\n";
410427
FunctionCoverageSummary Totals("TOTAL");
411428
for (const auto &F : Functions) {
@@ -418,7 +435,7 @@ void CoverageReport::renderFunctionReports(ArrayRef<std::string> Files,
418435
render(Function, DC, OS);
419436
}
420437
if (Totals.ExecutionCount) {
421-
renderDivider(FunctionReportColumns, OS);
438+
renderDivider(OS, Options, false);
422439
OS << "\n";
423440
render(Totals, DC, OS);
424441
}
@@ -544,7 +561,7 @@ void CoverageReport::renderFileReports(
544561
Column::RightAlignment)
545562
<< column("Cover", FileReportColumns[18], Column::RightAlignment);
546563
OS << "\n";
547-
renderDivider(FileReportColumns, OS);
564+
renderDivider(OS, Options, true);
548565
OS << "\n";
549566

550567
std::vector<const FileCoverageSummary *> EmptyFiles;
@@ -563,7 +580,7 @@ void CoverageReport::renderFileReports(
563580
render(*FCS, OS);
564581
}
565582

566-
renderDivider(FileReportColumns, OS);
583+
renderDivider(OS, Options, true);
567584
OS << "\n";
568585
render(Totals, OS);
569586
}

0 commit comments

Comments
 (0)