[llvm-cov] Unify region marker placement between text/html modes
Make sure that the text and html emitters always emit the same set of
region markers, and avoid emitting redundant markers for line segments
which don't end on the line they start on.
This is related to D35925, and depends on D36014
Differential Revision: https://reviews.llvm.org/D36020
llvm-svn: 312813
diff --git a/llvm/tools/llvm-cov/SourceCoverageViewText.cpp b/llvm/tools/llvm-cov/SourceCoverageViewText.cpp
index 4ad120f..a88558f 100644
--- a/llvm/tools/llvm-cov/SourceCoverageViewText.cpp
+++ b/llvm/tools/llvm-cov/SourceCoverageViewText.cpp
@@ -171,6 +171,10 @@
renderLinePrefix(OS, ViewDepth);
OS.indent(getCombinedColumnWidth(getOptions()));
+ // Just consider the segments which start *and* end on this line.
+ if (Segments.size() > 1)
+ Segments = Segments.drop_back();
+
unsigned PrevColumn = 1;
for (const auto *S : Segments) {
if (!S->IsRegionEntry)
@@ -182,13 +186,12 @@
std::string C = formatCount(S->Count);
PrevColumn += C.size();
OS << '^' << C;
+
+ if (getOptions().Debug)
+ errs() << "Marker at " << S->Line << ":" << S->Col << " = "
+ << formatCount(S->Count) << "\n";
}
OS << '\n';
-
- if (getOptions().Debug)
- for (const auto *S : Segments)
- errs() << "Marker at " << S->Line << ":" << S->Col << " = "
- << formatCount(S->Count) << (S->IsRegionEntry ? "\n" : " (pop)\n");
}
void SourceCoverageViewText::renderExpansionSite(