[llvm] r276906 - [llvm-cov] Minor aesthetic improvements for html reports

Vedant Kumar via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 27 12:51:17 PDT 2016


Author: vedantk
Date: Wed Jul 27 14:51:17 2016
New Revision: 276906

URL: http://llvm.org/viewvc/llvm-project?rev=276906&view=rev
Log:
[llvm-cov] Minor aesthetic improvements for html reports

This fixes the highlighting for lines without any coverage segments. I
don't have a neat way of testing this yet, but am working on it.

Modified:
    llvm/trunk/tools/llvm-cov/SourceCoverageViewHTML.cpp

Modified: llvm/trunk/tools/llvm-cov/SourceCoverageViewHTML.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/SourceCoverageViewHTML.cpp?rev=276906&r1=276905&r2=276906&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/SourceCoverageViewHTML.cpp (original)
+++ llvm/trunk/tools/llvm-cov/SourceCoverageViewHTML.cpp Wed Jul 27 14:51:17 2016
@@ -337,9 +337,9 @@ void SourceCoverageViewHTML::renderLine(
   for (unsigned I = 0, E = Snippets.size(); I < E; ++I)
     Snippets[I] = escape(Snippets[I]);
 
-  // 3. Use \p WrappedSegment to set the highlight for snippets 0 and 1. Use
-  //    segment 1 to set the highlight for snippet 2, segment 2 to set the
-  //    highlight for snippet 3, and so on.
+  // 3. Use \p WrappedSegment to set the highlight for snippet 0. Use segment
+  //    1 to set the highlight for snippet 2, segment 2 to set the highlight for
+  //    snippet 3, and so on.
 
   Optional<std::string> Color;
   auto Highlight = [&](const std::string &Snippet) {
@@ -347,17 +347,16 @@ void SourceCoverageViewHTML::renderLine(
   };
 
   auto CheckIfUncovered = [](const coverage::CoverageSegment *S) {
-    return S && S->HasCount && S->Count == 0;
+    return !S || (S->HasCount && S->Count == 0);
   };
 
   if (CheckIfUncovered(WrappedSegment) ||
       CheckIfUncovered(Segments.empty() ? nullptr : Segments.front())) {
     Color = "red";
     Snippets[0] = Highlight(Snippets[0]);
-    Snippets[1] = Highlight(Snippets[1]);
   }
 
-  for (unsigned I = 1, E = Segments.size(); I < E; ++I) {
+  for (unsigned I = 0, E = Segments.size(); I < E; ++I) {
     const auto *CurSeg = Segments[I];
     if (CurSeg->Col == ExpansionCol)
       Color = "cyan";
@@ -370,6 +369,9 @@ void SourceCoverageViewHTML::renderLine(
       Snippets[I + 1] = Highlight(Snippets[I + 1]);
   }
 
+  if (Color.hasValue() && Segments.empty())
+    Snippets.back() = Highlight(Snippets.back());
+
   // 4. Snippets[1:N+1] correspond to \p Segments[0:N]: use these to generate
   //    sub-line region count tooltips if needed.
 
@@ -390,7 +392,7 @@ void SourceCoverageViewHTML::renderLine(
 
       Snippets[I + 1] =
           tag("div", Snippets[I + 1] + tag("span", formatCount(CurSeg->Count),
-                                          "tooltip-content"),
+                                           "tooltip-content"),
               "tooltip");
     }
   }




More information about the llvm-commits mailing list