summaryrefslogtreecommitdiff
path: root/tools/llvm-cov/SourceCoverageView.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
commit2cefdfaa16cefd92de7aa6abedf706f23363b51c (patch)
tree33f95f13a22cc20365287c404f172c6216d51c6f /tools/llvm-cov/SourceCoverageView.cpp
parent400e98d4ca52f7abefdbbf1b92a80c11c6b0b8ce (diff)
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312813 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-cov/SourceCoverageView.cpp')
-rw-r--r--tools/llvm-cov/SourceCoverageView.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/tools/llvm-cov/SourceCoverageView.cpp b/tools/llvm-cov/SourceCoverageView.cpp
index 6630f3333bd..3806ee9c795 100644
--- a/tools/llvm-cov/SourceCoverageView.cpp
+++ b/tools/llvm-cov/SourceCoverageView.cpp
@@ -153,9 +153,17 @@ std::string SourceCoverageView::formatCount(uint64_t N) {
}
bool SourceCoverageView::shouldRenderRegionMarkers(
- bool LineHasMultipleRegions) const {
- return getOptions().ShowRegionMarkers &&
- (!getOptions().ShowLineStatsOrRegionMarkers || LineHasMultipleRegions);
+ CoverageSegmentArray Segments) const {
+ if (!getOptions().ShowRegionMarkers)
+ return false;
+
+ // Render the region markers if there's more than one count to show.
+ unsigned RegionCount = 0;
+ for (const auto *S : Segments)
+ if (S->IsRegionEntry)
+ if (++RegionCount > 1)
+ return true;
+ return false;
}
bool SourceCoverageView::hasSubViews() const {
@@ -261,7 +269,7 @@ void SourceCoverageView::print(raw_ostream &OS, bool WholeFile,
ExpansionColumn, ViewDepth);
// Show the region markers.
- if (shouldRenderRegionMarkers(LineCount.hasMultipleRegions()))
+ if (shouldRenderRegionMarkers(LineSegments))
renderRegionMarkers(OS, LineSegments, ViewDepth);
// Show the expansions and instantiations for this line.