Skip to content

Commit

Permalink
[llvm-cov] Highlight gaps in consecutive uncovered regions
Browse files Browse the repository at this point in the history
llvm-cov typically doesn't highlight gap segments, but it should if the
gap occurs after an uncovered region in order to preserve continuity.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316107 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
vedantk committed Oct 18, 2017
1 parent 7a600d3 commit 55fff37
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions test/tools/llvm-cov/deferred-region.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ int main() {
// MARKER-NEXT: Highlighted line 63, 5 -> 13
// MARKER-NEXT: Highlighted line 67, 1 -> ?
// MARKER-NEXT: Highlighted line 68, 1 -> 8
// MARKER-NEXT: Highlighted line 68, 8 -> ?
// MARKER-NEXT: Highlighted line 69, 1 -> 2
// MARKER-NEXT: Marker at 72:7 = 2
// MARKER-NEXT: Highlighted line 77, 1 -> 2
5 changes: 3 additions & 2 deletions tools/llvm-cov/SourceCoverageViewHTML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ void SourceCoverageViewHTML::renderLine(
// 1 to set the highlight for snippet 2, segment 2 to set the highlight for
// snippet 3, and so on.

Optional<std::string> Color;
Optional<StringRef> Color;
SmallVector<std::pair<unsigned, unsigned>, 2> HighlightedRanges;
auto Highlight = [&](const std::string &Snippet, unsigned LC, unsigned RC) {
if (getOptions().Debug)
Expand All @@ -528,7 +528,8 @@ void SourceCoverageViewHTML::renderLine(
const auto *CurSeg = Segments[I];
if (CurSeg->Col == ExpansionCol)
Color = "cyan";
else if (!CurSeg->IsGapRegion && CheckIfUncovered(CurSeg))
else if ((!CurSeg->IsGapRegion || (Color && *Color == "red")) &&
CheckIfUncovered(CurSeg))
Color = "red";
else
Color = None;
Expand Down
3 changes: 2 additions & 1 deletion tools/llvm-cov/SourceCoverageViewText.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ void SourceCoverageViewText::renderLine(
Col = End;
if (Col == ExpansionCol)
Highlight = raw_ostream::CYAN;
else if (!S->IsGapRegion && S->HasCount && S->Count == 0)
else if ((!S->IsGapRegion || Highlight == raw_ostream::RED) &&
S->HasCount && S->Count == 0)
Highlight = raw_ostream::RED;
else
Highlight = None;
Expand Down

0 comments on commit 55fff37

Please sign in to comment.