diff options
author | Petr Hosek <phosek@google.com> | 2022-03-04 22:20:42 -0800 |
---|---|---|
committer | Petr Hosek <phosek@google.com> | 2022-03-04 22:21:40 -0800 |
commit | b5f1a8cfc37a80027dbf005da4bf7da144bd9087 (patch) | |
tree | e4dda2b628de0f7c50889a34fee082d9e132baf5 /llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp | |
parent | fa9c8bab0c7a7aed423191baa8a980533ae5602a (diff) | |
download | llvm-b5f1a8cfc37a80027dbf005da4bf7da144bd9087.zip llvm-b5f1a8cfc37a80027dbf005da4bf7da144bd9087.tar.gz llvm-b5f1a8cfc37a80027dbf005da4bf7da144bd9087.tar.bz2 |
[llvm-cov] New parameters to set coverage coverage_watermark
Add a pairs of parameters to set coverage watermark for llvm-cov, and
user can change the percentage thresholds marked with different colors
in the report.
Patch By: tanjinhua
Differential Revision: https://reviews.llvm.org/D116876
Diffstat (limited to 'llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp')
-rw-r--r-- | llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp b/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp index 56efc40..a70b97b4 100644 --- a/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp +++ b/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp @@ -338,24 +338,24 @@ void CoveragePrinterHTML::emitFileSummary(raw_ostream &OS, StringRef SF, SmallVector<std::string, 8> Columns; // Format a coverage triple and add the result to the list of columns. - auto AddCoverageTripleToColumn = [&Columns](unsigned Hit, unsigned Total, - float Pctg) { - std::string S; - { - raw_string_ostream RSO{S}; - if (Total) - RSO << format("%*.2f", 7, Pctg) << "% "; - else - RSO << "- "; - RSO << '(' << Hit << '/' << Total << ')'; - } - const char *CellClass = "column-entry-yellow"; - 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)); - }; + auto AddCoverageTripleToColumn = + [&Columns, this](unsigned Hit, unsigned Total, float Pctg) { + std::string S; + { + raw_string_ostream RSO{S}; + if (Total) + RSO << format("%*.2f", 7, Pctg) << "% "; + else + RSO << "- "; + RSO << '(' << Hit << '/' << Total << ')'; + } + const char *CellClass = "column-entry-yellow"; + if (Pctg >= Opts.HighCovWatermark) + CellClass = "column-entry-green"; + else if (Pctg < Opts.LowCovWatermark) + CellClass = "column-entry-red"; + Columns.emplace_back(tag("td", tag("pre", S), CellClass)); + }; // Simplify the display file path, and wrap it in a link if requested. std::string Filename; |