From 35369c1eb6c4066a563c5a1766c5fb449dc85eb5 Mon Sep 17 00:00:00 2001 From: Alex Lorenz Date: Mon, 21 Nov 2016 14:00:04 +0000 Subject: [llvm-cov] Avoid 0% when reporting something that's 0/0 This commit makes llvm-cov avoid showing 0% (0/0) coverage for things like file function coverage, etc. in reports and HTML output. This can happen for files like headers that have macros but no functions. This commit makes llvm-cov report - (0/0) instead. rdar://29246480 Differential Revision: https://reviews.llvm.org/D26615 llvm-svn: 287539 --- llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp') diff --git a/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp b/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp index 8fc01ef0d88..64b888e89d7 100644 --- a/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp +++ b/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp @@ -307,13 +307,17 @@ void CoveragePrinterHTML::emitFileSummary(raw_ostream &OS, StringRef SF, std::string S; { raw_string_ostream RSO{S}; - RSO << format("%*.2f", 7, Pctg) << "% (" << Hit << '/' << Total << ')'; + if (Total) + RSO << format("%*.2f", 7, Pctg) << "% "; + else + RSO << "- "; + RSO << '(' << Hit << '/' << Total << ')'; } const char *CellClass = "column-entry-yellow"; - if (Pctg < 80.0) - CellClass = "column-entry-red"; - else if (Hit == Total) + if (Hit == Total) CellClass = "column-entry-green"; + else if (Pctg < 80.0) + CellClass = "column-entry-red"; Columns.emplace_back(tag("td", tag("pre", S), CellClass)); }; -- cgit v1.2.3