[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)
Jessica Paquette via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 6 20:18:20 PST 2025
================
@@ -938,6 +938,37 @@ struct CounterCoverageMappingBuilder
return Counter::getCounter(CounterMap[S]);
}
+ struct BranchCounterPair {
----------------
ornata wrote:
IIUC the point of this pair is given:
```
if (x) {
// ... do something
} else if (y) {
// ... something else
} else {
// ... another something else
}
```
You want to track, _from the perspective of a branch_, how many times it is executed.
For example, there will be a `BranchAndCounterPair` for the `if`, the `else if`, and the `else`.
Assuming I'm understanding this correctly, I think we could explain this struct like so:
```
/// Structure to track how many times a conditional was executed or skipped over when evaluated at runtime.
///
/// E.g. given a conditional like
///
/// if (x) {...}
///
/// Keep track of the number of times the `if` branch is taken, and the number of times it is not taken.
```
https://github.com/llvm/llvm-project/pull/112702
More information about the cfe-commits
mailing list