aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-cov
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools/llvm-cov')
-rw-r--r--llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp12
-rw-r--r--llvm/tools/llvm-cov/SourceCoverageViewText.cpp11
2 files changed, 12 insertions, 11 deletions
diff --git a/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp b/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
index e839184..7e9fc23 100644
--- a/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
+++ b/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
@@ -514,8 +514,9 @@ void SourceCoverageViewHTML::renderLine(raw_ostream &OS, LineRef L,
return tag("span", Snippet, Color.getValue());
};
- auto CheckIfUncovered = [](const CoverageSegment *S) {
- return S && S->HasCount && S->Count == 0;
+ auto CheckIfUncovered = [&](const CoverageSegment *S) {
+ return S && (!S->IsGapRegion || (Color && *Color == "red")) &&
+ S->HasCount && S->Count == 0;
};
if (CheckIfUncovered(LCS.getWrappedSegment())) {
@@ -526,11 +527,10 @@ void SourceCoverageViewHTML::renderLine(raw_ostream &OS, LineRef L,
for (unsigned I = 0, E = Segments.size(); I < E; ++I) {
const auto *CurSeg = Segments[I];
- if (CurSeg->Col == ExpansionCol)
- Color = "cyan";
- else if ((!CurSeg->IsGapRegion || (Color && *Color == "red")) &&
- CheckIfUncovered(CurSeg))
+ if (CheckIfUncovered(CurSeg))
Color = "red";
+ else if (CurSeg->Col == ExpansionCol)
+ Color = "cyan";
else
Color = None;
diff --git a/llvm/tools/llvm-cov/SourceCoverageViewText.cpp b/llvm/tools/llvm-cov/SourceCoverageViewText.cpp
index 4b69b08..2480ee9 100644
--- a/llvm/tools/llvm-cov/SourceCoverageViewText.cpp
+++ b/llvm/tools/llvm-cov/SourceCoverageViewText.cpp
@@ -106,7 +106,8 @@ void SourceCoverageViewText::renderLine(raw_ostream &OS, LineRef L,
SmallVector<std::pair<unsigned, unsigned>, 2> HighlightedRanges;
// The first segment overlaps from a previous line, so we treat it specially.
- if (WrappedSegment && WrappedSegment->HasCount && WrappedSegment->Count == 0)
+ if (WrappedSegment && !WrappedSegment->IsGapRegion &&
+ WrappedSegment->HasCount && WrappedSegment->Count == 0)
Highlight = raw_ostream::RED;
// Output each segment of the line, possibly highlighted.
@@ -120,11 +121,11 @@ void SourceCoverageViewText::renderLine(raw_ostream &OS, LineRef L,
if (getOptions().Debug && Highlight)
HighlightedRanges.push_back(std::make_pair(Col, End));
Col = End;
- if (Col == ExpansionCol)
- Highlight = raw_ostream::CYAN;
- else if ((!S->IsGapRegion || Highlight == raw_ostream::RED) &&
- S->HasCount && S->Count == 0)
+ if ((!S->IsGapRegion || (Highlight && *Highlight == raw_ostream::RED)) &&
+ S->HasCount && S->Count == 0)
Highlight = raw_ostream::RED;
+ else if (Col == ExpansionCol)
+ Highlight = raw_ostream::CYAN;
else
Highlight = None;
}