BitVecForeachReverseIdx
- Macro
- October 8, 2025
Table of Contents
BitVecForeachReverseIdx
BitVecForeachReverseIdxDescription
Iterate over each bit var of given bitvector bv at each index idx into the bitvector. The variables var and idx declared and defined by this macro. idx will start from bv->length - 1 and will go till 0
Parameters
| Name | Direction | Description |
|---|---|---|
bv | in,out | Bitvector to iterate over. |
var | in | Name of variable to be used which’ll contain bit value at iterated index idx |
idx | in | Name of variable to be used for iterating over indices. |
Usage example (Cross-references)
// Test BitVecForeachReverseIdx macro
bool test_bitvec_foreach_reverse_idx(void) {
WriteFmt("Testing BitVecForeachReverseIdx macro\n");
BitVec bv = BitVecInit();
bool first_bit_is_false = false; // Should be last bit when iterating in reverse
BitVecForeachReverseIdx(&bv, bit, idx) {
if (count == 0) {
first_bit_is_false = (bit == false) && (idx == 3);
count3++;
}
BitVecForeachReverseIdx(&bv, bitval, i) {
(void)bitval;
count4++;
// Test BitVecForeachReverseIdx macro
bool test_bitvec_foreach_reverse_idx(void) {
WriteFmt("Testing BitVecForeachReverseIdx macro\n");
BitVec bv = BitVecInit();
bool first_bit_is_false = false; // Should be last bit when iterating in reverse
BitVecForeachReverseIdx(&bv, bit, idx) {
if (count == 0) {
first_bit_is_false = (bit == false) && (idx == 3);
count3++;
}
BitVecForeachReverseIdx(&bv, bitval, i) {
(void)bitval;
count4++;
- In
Foreach.h:66:
/// current bit during iteration. The type of `var` will be `bool`.
///
#define BitVecForeachReverse(bv, var) BitVecForeachReverseIdx((bv), (var), UNPL(iter))
///