diff options
author | Justin Cady <desk@justincady.com> | 2025-05-19 15:49:26 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-19 15:49:26 -0400 |
commit | 025639bc396f1e0d2ead279c5f345cb381733f16 (patch) | |
tree | 68fe437b9458282d1da75e605623d2394f9aa09b /clang/lib/CodeGen/CoverageMappingGen.cpp | |
parent | 36018494fdb9e92e0f61f6937e5ecd3a4472677f (diff) | |
download | llvm-025639bc396f1e0d2ead279c5f345cb381733f16.zip llvm-025639bc396f1e0d2ead279c5f345cb381733f16.tar.gz llvm-025639bc396f1e0d2ead279c5f345cb381733f16.tar.bz2 |
[Coverage] Fix mapping for do-while loops with terminating statements (#139777)
The current region mapping for do-while loops that contain statements
such as break or continue results in inaccurate line coverage reports
for the line following the loop.
This change handles terminating statements the same way that other loop
constructs do, correcting the region mapping for accurate reports. It
also fixes a fragile test relying on exact line numbers.
Fixes #139122
Diffstat (limited to 'clang/lib/CodeGen/CoverageMappingGen.cpp')
-rw-r--r-- | clang/lib/CodeGen/CoverageMappingGen.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp b/clang/lib/CodeGen/CoverageMappingGen.cpp index 73811d1..6170dc7 100644 --- a/clang/lib/CodeGen/CoverageMappingGen.cpp +++ b/clang/lib/CodeGen/CoverageMappingGen.cpp @@ -1703,14 +1703,13 @@ struct CounterCoverageMappingBuilder if (!IsCounterEqual(OutCount, ParentCount)) { pushRegion(OutCount); GapRegionCounter = OutCount; + if (BodyHasTerminateStmt) + HasTerminateStmt = true; } // Create Branch Region around condition. if (!llvm::EnableSingleByteCoverage) createBranchRegion(S->getCond(), BodyCount, BranchCount.Skipped); - - if (BodyHasTerminateStmt) - HasTerminateStmt = true; } void VisitForStmt(const ForStmt *S) { |