diff options
author | Alex Lorenz <arphaman@gmail.com> | 2016-11-21 14:00:04 +0000 |
---|---|---|
committer | Alex Lorenz <arphaman@gmail.com> | 2016-11-21 14:00:04 +0000 |
commit | 35369c1eb6c4066a563c5a1766c5fb449dc85eb5 (patch) | |
tree | 6d13b621bf3d3bdd02d127965f9f535acdd864c7 /llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp | |
parent | 91972d7f9d9ab4c4db34bc003df1064ae5805736 (diff) | |
download | bcm5719-llvm-35369c1eb6c4066a563c5a1766c5fb449dc85eb5.tar.gz bcm5719-llvm-35369c1eb6c4066a563c5a1766c5fb449dc85eb5.zip |
[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
Diffstat (limited to 'llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp')
-rw-r--r-- | llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
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)); }; |