From 69597042ff9058e98745f9a54ec5ee5818378330 Mon Sep 17 00:00:00 2001 From: Vedant Kumar Date: Thu, 9 Nov 2017 02:33:44 +0000 Subject: [llvm-cov] Don't render empty region marker lines This fixes an issue where llvm-cov prints an empty line, thinking it needs to display region markers, when it actually doesn't. llvm-svn: 317762 --- llvm/tools/llvm-cov/SourceCoverageView.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 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 31ab1325c7b..8c39dab580d 100644 --- a/llvm/tools/llvm-cov/SourceCoverageView.cpp +++ b/llvm/tools/llvm-cov/SourceCoverageView.cpp @@ -111,16 +111,19 @@ std::string SourceCoverageView::formatCount(uint64_t N) { } bool SourceCoverageView::shouldRenderRegionMarkers( - CoverageSegmentArray Segments) const { + const LineCoverageStats &LCS) 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; + CoverageSegmentArray Segments = LCS.getLineSegments(); + if (Segments.empty()) + return false; + for (unsigned I = 0, E = Segments.size() - 1; I < E; ++I) { + const auto *CurSeg = Segments[I]; + if (!CurSeg->IsRegionEntry || CurSeg->Count == LCS.getExecutionCount()) + continue; + return true; + } return false; } @@ -220,7 +223,7 @@ void SourceCoverageView::print(raw_ostream &OS, bool WholeFile, renderLine(OS, {*LI, LI.line_number()}, *LCI, ExpansionColumn, ViewDepth); // Show the region markers. - if (shouldRenderRegionMarkers(LCI->getLineSegments())) + if (shouldRenderRegionMarkers(*LCI)) renderRegionMarkers(OS, *LCI, ViewDepth); // Show the expansions and instantiations for this line. -- cgit v1.2.3