[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

Jessica Paquette via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 7 22:03:59 PST 2025


================
@@ -939,8 +939,17 @@ struct CounterCoverageMappingBuilder
     Counter Skipped;
   };
 
-  BranchCounterPair getBranchCounterPair(const Stmt *S, Counter ParentCnt) {
+  BranchCounterPair
+  getBranchCounterPair(const Stmt *S, Counter ParentCnt,
+                       std::optional<Counter> SkipCntForOld = std::nullopt) {
     Counter ExecCnt = getRegionCounter(S);
+
+    // The old behavior of SingleByte shouldn't emit Branches.
+    if (llvm::EnableSingleByteCoverage) {
+      assert(SkipCntForOld);
----------------
ornata wrote:

Can you add a string this this assert like

```
assert(SkipCntForOld && "Single byte coverage shouldn't emit branches when using old behaviour!");
```

Or something?

https://github.com/llvm/llvm-project/pull/112702


More information about the cfe-commits mailing list