mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-04 12:15:46 +00:00
[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
This commit is contained in:
parent
43247f0542
commit
69597042ff
@ -2,7 +2,7 @@
|
||||
|
||||
void foo(int x) {
|
||||
if (x == 0) { // CHECK: [[@LINE]]|{{ +}}2|
|
||||
return; // CHECK: [[@LINE]]|{{ +}}1|
|
||||
return; // CHECK-NEXT: [[@LINE]]|{{ +}}1|
|
||||
}
|
||||
|
||||
} // CHECK: [[@LINE]]|{{ +}}1|
|
||||
|
@ -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.
|
||||
|
@ -225,7 +225,7 @@ protected:
|
||||
static std::string formatCount(uint64_t N);
|
||||
|
||||
/// \brief Check if region marker output is expected for a line.
|
||||
bool shouldRenderRegionMarkers(CoverageSegmentArray Segments) const;
|
||||
bool shouldRenderRegionMarkers(const LineCoverageStats &LCS) const;
|
||||
|
||||
/// \brief Check if there are any sub-views attached to this view.
|
||||
bool hasSubViews() const;
|
||||
|
@ -556,7 +556,7 @@ void SourceCoverageViewHTML::renderLine(raw_ostream &OS, LineRef L,
|
||||
// 4. Snippets[1:N+1] correspond to \p Segments[0:N]: use these to generate
|
||||
// sub-line region count tooltips if needed.
|
||||
|
||||
if (shouldRenderRegionMarkers(Segments)) {
|
||||
if (shouldRenderRegionMarkers(LCS)) {
|
||||
// Just consider the segments which start *and* end on this line.
|
||||
for (unsigned I = 0, E = Segments.size() - 1; I < E; ++I) {
|
||||
const auto *CurSeg = Segments[I];
|
||||
|
Loading…
Reference in New Issue
Block a user