From b28eef39f7eb61ba8d4341b6bddb25a7132bfe3f Mon Sep 17 00:00:00 2001 From: Mike Aizatsky Date: Fri, 19 Feb 2016 22:55:08 +0000 Subject: [PATCH] [sancov] sanitizer html report cosmetic improvements. llvm-svn: 261375 --- llvm/tools/sancov/sancov.cc | 40 +++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/llvm/tools/sancov/sancov.cc b/llvm/tools/sancov/sancov.cc index f9fc9e0d4e84..82c5916072be 100644 --- a/llvm/tools/sancov/sancov.cc +++ b/llvm/tools/sancov/sancov.cc @@ -795,15 +795,20 @@ public: // TOC + size_t NotCoveredFilesCount = 0; + std::set Files = SCovData.files(); + // Covered Files. - OS << "
Covered Files\n"; + OS << "
Touched Files\n"; OS << "\n"; OS << ""; OS << "\n"; - for (auto FileName : SCovData.files()) { + for (auto FileName : Files) { std::pair FC = FileFnCoverage[FileName]; - if (FC.first == 0) + if (FC.first == 0) { + NotCoveredFilesCount++; continue; + } size_t CovPct = FC.second == 0 ? 100 : 100 * FC.first / FC.second; OS << "
FileHit Fns %Hit (Total) Fns
" @@ -816,18 +821,22 @@ public: OS << "\n"; // Not covered files. - OS << "
Not Covered Files\n"; - OS << "\n"; - for (auto FileName : SCovData.files()) { - std::pair FC = FileFnCoverage[FileName]; - if (FC.first == 0) - OS << "\n"; + if (NotCoveredFilesCount) { + OS << "
Not Touched Files\n"; + OS << "
" << stripPathPrefix(FileName) << "
\n"; + for (auto FileName : Files) { + std::pair FC = FileFnCoverage[FileName]; + if (FC.first == 0) + OS << "\n"; + } + OS << "
" << stripPathPrefix(FileName) << "
\n"; + OS << "
\n"; + } else { + OS << "

Congratulations! All source files are touched.

\n"; } - OS << "
\n"; - OS << "
\n"; // Source - for (auto FileName : SCovData.files()) { + for (auto FileName : Files) { std::pair FC = FileFnCoverage[FileName]; if (FC.first == 0) continue; @@ -841,7 +850,7 @@ public: for (auto FileFn : NotCoveredFns->second) { OS << ""; OS << ""; + << escapeHtml(FileName + "::" + FileFn.FunctionName) << "\">"; OS << escapeHtml(FileFn.FunctionName) << ""; OS << "\n"; } @@ -867,7 +876,7 @@ public: auto It = NotCoveredFnByLoc.find(Loc); if (It != NotCoveredFnByLoc.end()) { for (std::string Fn : It->second) { - OS << ""; }; } @@ -992,7 +1001,7 @@ public: } void printReport(raw_ostream &OS) const { - std::string Title = stripPathPrefix(MainObjFile) + " Coverage Report"; + auto Title = llvm::sys::path::filename(MainObjFile) + " Coverage Report"; OS << "\n"; OS << "\n"; @@ -1001,6 +1010,7 @@ public: OS << "\n";