From: Vedant Kumar Date: Wed, 21 Oct 2015 16:03:32 +0000 (+0000) Subject: [llvm-cov] Adjust column widths for function and file reports X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=f890225b786ddf6845bdfbdc9ba4a6f9f00645b1 [llvm-cov] Adjust column widths for function and file reports Previously, we only expanded function and filename column widths when rendering file reports. This commit makes the change for function reports as well. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250900 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/tools/llvm-cov/CoverageReport.cpp b/tools/llvm-cov/CoverageReport.cpp index 7cab7b6c55c..ed01a2e154f 100644 --- a/tools/llvm-cov/CoverageReport.cpp +++ b/tools/llvm-cov/CoverageReport.cpp @@ -91,6 +91,17 @@ static Column column(StringRef Str, unsigned Width, const T &Value) { static size_t FileReportColumns[] = {25, 10, 8, 8, 10, 10}; static size_t FunctionReportColumns[] = {25, 10, 8, 8, 10, 8, 8}; +/// \brief Adjust column widths to fit long file paths and function names. +static void adjustColumnWidths(coverage::CoverageMapping *CM) { + for (StringRef Filename : CM->getUniqueSourceFiles()) { + FileReportColumns[0] = std::max(FileReportColumns[0], Filename.size()); + for (const auto &F : CM->getCoveredFunctions(Filename)) { + FunctionReportColumns[0] = + std::max(FunctionReportColumns[0], F.Name.size()); + } + } +} + /// \brief Prints a horizontal divider which spans across the given columns. template static void renderDivider(T (&Columns)[N], raw_ostream &OS) { @@ -162,6 +173,7 @@ void CoverageReport::render(const FunctionCoverageSummary &Function, void CoverageReport::renderFunctionReports(ArrayRef Files, raw_ostream &OS) { + adjustColumnWidths(Coverage.get()); bool isFirst = true; for (StringRef Filename : Files) { if (isFirst) @@ -196,15 +208,7 @@ void CoverageReport::renderFunctionReports(ArrayRef Files, } void CoverageReport::renderFileReports(raw_ostream &OS) { - // Adjust column widths to accomodate long paths and names. - for (StringRef Filename : Coverage->getUniqueSourceFiles()) { - FileReportColumns[0] = std::max(FileReportColumns[0], Filename.size()); - for (const auto &F : Coverage->getCoveredFunctions(Filename)) { - FunctionReportColumns[0] = - std::max(FunctionReportColumns[0], F.Name.size()); - } - } - + adjustColumnWidths(Coverage.get()); OS << column("Filename", FileReportColumns[0]) << column("Regions", FileReportColumns[1], Column::RightAlignment) << column("Miss", FileReportColumns[2], Column::RightAlignment)