BitVecForeach
Description
Iterate over each bit var of the given bitvector bv. This is a convenience macro that iterates forward using an internally managed index. The variable var is declared and defined by this macro.
Parameters
| Name | Direction | Description |
|---|---|---|
bv |
in,out | Bitvector to iterate over. |
var |
in | Name of the variable to be used which will contain the value of the current bit during iteration. The type of var will be bool. |
Success
Loop body runs once per bit; var carries the current bit value.
Failure
Loop body never executes when bv is empty; validator aborts on corrupted magic.
Usage example (Cross-references)
Usage examples (Cross-references)
// This should abort due to ValidateBitVec check
int count = 0;
BitVecForeach(&bv, bit) {
(void)bit;
count++; DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVecForeach macro\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); u64 false_count = 0;
BitVecForeach(&bv, bit) {
if (bit) {
true_count++;
// Test foreach on empty bitvec
BitVecForeach(&bv, bit) {
(void)bit;
count++; // Should not execute
BitVecPush(&bv, true);
count = 0;
BitVecForeach(&bv, bit) {
count++;
result = result && (bit == true);
count = 0;
BitVecForeach(&bv, bit) {
(void)bit;
count++; int count1 = 0, count2 = 0, count3 = 0, count4 = 0;
BitVecForeach(&bv, bitval) {
(void)bitval;
count1++; DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVecForeach macro\n");
BitVec bv = BitVecInit(ALLOCATOR_OF(&alloc)); u64 false_count = 0;
BitVecForeach(&bv, bit) {
if (bit) {
true_count++;
// Test foreach on empty bitvec
BitVecForeach(&bv, bit) {
(void)bit;
count++; // Should not execute
BitVecPush(&bv, true);
count = 0;
BitVecForeach(&bv, bit) {
count++;
result = result && (bit == true);
count = 0;
BitVecForeach(&bv, bit) {
(void)bit;
count++; int count1 = 0, count2 = 0, count3 = 0, count4 = 0;
BitVecForeach(&bv, bitval) {
(void)bitval;
count1++; // This should abort due to ValidateBitVec check
int count = 0;
BitVecForeach(&bv, bit) {
(void)bit;
count++;
Last updated on