summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-cov
diff options
context:
space:
mode:
authorVedant Kumar <vsk@apple.com>2016-09-08 19:18:23 +0000
committerVedant Kumar <vsk@apple.com>2016-09-08 19:18:23 +0000
commit0b33f2c0032088e890f929f11ba559091182a8f9 (patch)
treeceda599869596fa590e7e22faa4c65a58dd60216 /llvm/tools/llvm-cov
parent55f9f18cb2ea5b843bdff373b97f265ce288f1ec (diff)
downloadbcm5719-llvm-0b33f2c0032088e890f929f11ba559091182a8f9.tar.gz
bcm5719-llvm-0b33f2c0032088e890f929f11ba559091182a8f9.zip
[llvm-cov] Fix issues with segment highlighting in the html view
The text and html coverage views take different approaches to emitting highlighted regions. That's because this problem is easier in the text view: there's no need to worry about escaping text or adding tooltip content to a highlighted snippet. Unfortunately, the html view didn't get region highlighting quite right. This patch fixes the situation, bringing parity between the two views. llvm-svn: 280981
Diffstat (limited to 'llvm/tools/llvm-cov')
-rw-r--r--llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp26
1 files changed, 10 insertions, 16 deletions
diff --git a/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp b/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
index ca3f350ff7a..17353b553f9 100644
--- a/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
+++ b/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
@@ -415,26 +415,21 @@ void SourceCoverageViewHTML::renderLine(
// snippet 3, and so on.
Optional<std::string> Color;
- SmallVector<std::pair<unsigned, unsigned>, 4> HighlightedRanges;
+ SmallVector<std::pair<unsigned, unsigned>, 2> HighlightedRanges;
auto Highlight = [&](const std::string &Snippet, unsigned LC, unsigned RC) {
- if (getOptions().Debug) {
- if (!HighlightedRanges.empty() &&
- HighlightedRanges.back().second == LC - 1) {
- HighlightedRanges.back().second = RC;
- } else
- HighlightedRanges.emplace_back(LC, RC);
- }
+ if (getOptions().Debug)
+ HighlightedRanges.emplace_back(LC, RC);
return tag("span", Snippet, Color.getValue());
};
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())) {
+ if (CheckIfUncovered(WrappedSegment)) {
Color = "red";
- Snippets[0] = Highlight(Snippets[0], 0, Snippets[0].size());
+ if (!Snippets[0].empty())
+ Snippets[0] = Highlight(Snippets[0], 1, 1 + Snippets[0].size());
}
for (unsigned I = 0, E = Segments.size(); I < E; ++I) {
@@ -452,16 +447,15 @@ void SourceCoverageViewHTML::renderLine(
}
if (Color.hasValue() && Segments.empty())
- Snippets.back() = Highlight(Snippets.back(), Snippets[0].size(), 0);
+ Snippets.back() = Highlight(Snippets.back(), 1, 1 + Snippets.back().size());
if (getOptions().Debug) {
for (const auto &Range : HighlightedRanges) {
- errs() << "Highlighted line " << LineNo << ", " << Range.first + 1
- << " -> ";
+ errs() << "Highlighted line " << LineNo << ", " << Range.first << " -> ";
if (Range.second == 0)
errs() << "?";
else
- errs() << Range.second + 1;
+ errs() << Range.second;
errs() << "\n";
}
}
OpenPOWER on IntegriCloud