aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-cov/SourceCoverageViewText.cpp
diff options
context:
space:
mode:
authorVedant Kumar <vsk@apple.com>2017-09-08 18:44:46 +0000
committerVedant Kumar <vsk@apple.com>2017-09-08 18:44:46 +0000
commit933b37f99f4f6f2ca3ab0d268caafc33c50bee84 (patch)
treee55936ba795b66684453481b0ef3f3f6c386ebf9 /llvm/tools/llvm-cov/SourceCoverageViewText.cpp
parentee6a352a8ddfd3bf7b7dea95bc2d7d7df0b9aa5f (diff)
downloadllvm-933b37f99f4f6f2ca3ab0d268caafc33c50bee84.zip
llvm-933b37f99f4f6f2ca3ab0d268caafc33c50bee84.tar.gz
llvm-933b37f99f4f6f2ca3ab0d268caafc33c50bee84.tar.bz2
[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
Diffstat (limited to 'llvm/tools/llvm-cov/SourceCoverageViewText.cpp')
-rw-r--r--llvm/tools/llvm-cov/SourceCoverageViewText.cpp13
1 files changed, 8 insertions, 5 deletions
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 @@ void SourceCoverageViewText::renderRegionMarkers(
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 @@ void SourceCoverageViewText::renderRegionMarkers(
std::string C = formatCount(S->Count);
PrevColumn += C.size();
OS << '^' << C;
- }
- OS << '\n';
- if (getOptions().Debug)
- for (const auto *S : Segments)
+ if (getOptions().Debug)
errs() << "Marker at " << S->Line << ":" << S->Col << " = "
- << formatCount(S->Count) << (S->IsRegionEntry ? "\n" : " (pop)\n");
+ << formatCount(S->Count) << "\n";
+ }
+ OS << '\n';
}
void SourceCoverageViewText::renderExpansionSite(