diff options
-rw-r--r-- | llvm/test/tools/llvm-cov/showLineExecutionCounts.cpp | 4 | ||||
-rw-r--r-- | llvm/tools/llvm-cov/SourceCoverageView.h | 7 |
2 files changed, 5 insertions, 6 deletions
diff --git a/llvm/test/tools/llvm-cov/showLineExecutionCounts.cpp b/llvm/test/tools/llvm-cov/showLineExecutionCounts.cpp index 34baa574dab..625c3f2732d 100644 --- a/llvm/test/tools/llvm-cov/showLineExecutionCounts.cpp +++ b/llvm/test/tools/llvm-cov/showLineExecutionCounts.cpp @@ -12,11 +12,11 @@ int main() { // CHECK: 1| [[@LINE]]|int main( x = 1; // CHECK: 1| [[@LINE]]| x = 1 } // CHECK: 1| [[@LINE]]| } // CHECK: 1| [[@LINE]]| - for (int i = 0; i < 100; ++i) { // CHECK: 100| [[@LINE]]| for ( + for (int i = 0; i < 100; ++i) { // CHECK: 101| [[@LINE]]| for ( x = 1; // CHECK: 100| [[@LINE]]| x = 1 } // CHECK: 100| [[@LINE]]| } // CHECK: 1| [[@LINE]]| - x = x < 10 ? x + 1 : x - 1; // CHECK: 0| [[@LINE]]| x = + x = x < 10 ? x + 1 : x - 1; // CHECK: 1| [[@LINE]]| x = x = x > 10 ? // CHECK: 1| [[@LINE]]| x = x - 1: // CHECK: 0| [[@LINE]]| x x + 1; // CHECK: 1| [[@LINE]]| x diff --git a/llvm/tools/llvm-cov/SourceCoverageView.h b/llvm/tools/llvm-cov/SourceCoverageView.h index d92a7486d9d..9e6fe5f3500 100644 --- a/llvm/tools/llvm-cov/SourceCoverageView.h +++ b/llvm/tools/llvm-cov/SourceCoverageView.h @@ -90,15 +90,14 @@ private: bool hasMultipleRegions() const { return RegionCount > 1; } void addRegionStartCount(uint64_t Count) { - Mapped = true; - ExecutionCount = Count; + // The max of all region starts is the most interesting value. + addRegionCount(RegionCount ? std::max(ExecutionCount, Count) : Count); ++RegionCount; } void addRegionCount(uint64_t Count) { Mapped = true; - if (!RegionCount) - ExecutionCount = Count; + ExecutionCount = Count; } }; |