From 933b37f99f4f6f2ca3ab0d268caafc33c50bee84 Mon Sep 17 00:00:00 2001 From: Vedant Kumar Date: Fri, 8 Sep 2017 18:44:46 +0000 Subject: [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 --- llvm/tools/llvm-cov/SourceCoverageView.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'llvm/tools/llvm-cov/SourceCoverageView.cpp') diff --git a/llvm/tools/llvm-cov/SourceCoverageView.cpp b/llvm/tools/llvm-cov/SourceCoverageView.cpp index 6630f33..3806ee9 100644 --- a/llvm/tools/llvm-cov/SourceCoverageView.cpp +++ b/llvm/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. -- cgit v1.1