[llvm-cov] Turn line numbers in html reports into clickable links

llvm-svn: 285853
This commit is contained in:
Vedant Kumar
2016-11-02 19:44:13 +00:00
parent 47fec16cd1
commit 5a0e92b04c
3 changed files with 60 additions and 58 deletions

View File

@@ -64,8 +64,9 @@ std::string tag(const std::string &Name, const std::string &Str,
// Create an anchor to \p Link with the label \p Str.
std::string a(const std::string &Link, const std::string &Str,
const std::string &TargetType = "href") {
return "<a " + TargetType + "='" + Link + "'>" + Str + "</a>";
const std::string &TargetName = "") {
std::string Name = TargetName.empty() ? "" : ("name='" + TargetName + "' ");
return "<a " + Name + "href='" + Link + "'>" + Str + "</a>";
}
const char *BeginHeader =
@@ -560,7 +561,8 @@ void SourceCoverageViewHTML::renderLineCoverageColumn(
void SourceCoverageViewHTML::renderLineNumberColumn(raw_ostream &OS,
unsigned LineNo) {
std::string LineNoStr = utostr(uint64_t(LineNo));
OS << tag("td", a("L" + LineNoStr, tag("pre", LineNoStr), "name"),
std::string TargetName = "L" + LineNoStr;
OS << tag("td", a("#" + TargetName, tag("pre", LineNoStr), TargetName),
"line-number");
}