aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
diff options
context:
space:
mode:
authorHana Dusíková <hanicka@hanicka.net>2024-01-22 12:50:20 +0100
committerGitHub <noreply@github.com>2024-01-22 12:50:20 +0100
commit865e4a1f33bd3be42ff256c6839aff0860610a5a (patch)
tree88d4dd44b81c2a951553cacdc45c690f0ce9799d /llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
parent1a5eeade161beddf9c8b2fabad56af3081cd3629 (diff)
downloadllvm-865e4a1f33bd3be42ff256c6839aff0860610a5a.zip
llvm-865e4a1f33bd3be42ff256c6839aff0860610a5a.tar.gz
llvm-865e4a1f33bd3be42ff256c6839aff0860610a5a.tar.bz2
[coverage] skipping code coverage for 'if constexpr' and 'if consteval' (#78033)
`if constexpr` and `if consteval` conditional statements code coverage should behave more like a preprocesor `#if`-s than normal ConditionalStmt. This PR should fix that. --------- Co-authored-by: cor3ntin <corentinjabot@gmail.com>
Diffstat (limited to 'llvm/lib/ProfileData/Coverage/CoverageMapping.cpp')
-rw-r--r--llvm/lib/ProfileData/Coverage/CoverageMapping.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
index eece6a2..d8be7be 100644
--- a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
+++ b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
@@ -1319,8 +1319,15 @@ LineCoverageStats::LineCoverageStats(
!StartOfSkippedRegion &&
((WrappedSegment && WrappedSegment->HasCount) || (MinRegionCount > 0));
- if (!Mapped)
+ // if there is any starting segment at this line with a counter, it must be
+ // mapped
+ Mapped |= std::any_of(
+ LineSegments.begin(), LineSegments.end(),
+ [](const auto *Seq) { return Seq->IsRegionEntry && Seq->HasCount; });
+
+ if (!Mapped) {
return;
+ }
// Pick the max count from the non-gap, region entry segments and the
// wrapped count.