[PATCH] D18420: [sancov] adding leading zeros to coverage pct.
Mike Aizatsky via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 24 10:24:04 PDT 2016
aizatsky updated this revision to Diff 51569.
aizatsky added a comment.
giving zeroes a shade of gray.
http://reviews.llvm.org/D18420
Files:
tools/sancov/sancov.cc
Index: tools/sancov/sancov.cc
===================================================================
--- tools/sancov/sancov.cc
+++ tools/sancov/sancov.cc
@@ -46,6 +46,7 @@
#include "llvm/Support/ToolOutputFile.h"
#include "llvm/Support/raw_ostream.h"
+#include <algorithm>
#include <set>
#include <stdio.h>
#include <string>
@@ -490,6 +491,24 @@
return Result;
}
+// Adds leading zeroes wrapped in 'lz' style.
+// Leading zeroes help locate 000% coverage.
+static std::string formatHtmlPct(size_t Pct) {
+ Pct = std::max(std::size_t{0}, std::min(std::size_t{100}, Pct));
+
+ std::string Zeroes;
+
+ if (Pct < 10)
+ Zeroes = "00";
+ else if (Pct < 100)
+ Zeroes = "0";
+
+ if (!Zeroes.empty())
+ Zeroes = "<span class='lz'>" + Zeroes + "</span>";
+
+ return Zeroes + std::to_string(Pct);
+}
+
static std::string anchorName(std::string Anchor) {
llvm::MD5 Hasher;
llvm::MD5::MD5Result Hash;
@@ -885,7 +904,7 @@
OS << "<tr><td><a href=\"#" << anchorName(FileName) << "\">"
<< stripPathPrefix(FileName) << "</a></td>"
- << "<td>" << CovPct << "%</td>"
+ << "<td>" << formatHtmlPct(CovPct) << "%</td>"
<< "<td>" << FC.first << " (" << FC.second << ")"
<< "</tr>\n";
}
@@ -923,7 +942,8 @@
std::string FunctionName = P.first.FunctionName;
OS << "<div class='fn' style='order: " << P.second << "'>";
- OS << "<span class='pct'>" << P.second << "%</span> ";
+ OS << "<span class='pct'>" << formatHtmlPct(P.second)
+ << "%</span> ";
OS << "<span class='name'><a href=\"#"
<< anchorName(FileName + "::" + FunctionName) << "\">";
OS << escapeHtml(FunctionName) << "</a></span>";
@@ -1108,6 +1128,7 @@
OS << ".fn { display: flex; flex-flow: row nowrap; }\n";
OS << ".pct { width: 3em; text-align: right; margin-right: 1em; }\n";
OS << ".name { flex: 2; }\n";
+ OS << ".lz { color: lightgray; }\n";
OS << "</style>\n";
OS << "<title>" << Title << "</title>\n";
OS << "</head>\n";
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18420.51569.patch
Type: text/x-patch
Size: 2076 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160324/23e969dc/attachment.bin>
More information about the llvm-commits
mailing list