Skip to content

BitVecForeach

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.

Usage example (Cross-references)

Usage examples (Cross-references)
    // Test BitVecForeach macro
    bool test_bitvec_foreach(void) {
        WriteFmt("Testing BitVecForeach macro\n");
    
        BitVec bv = BitVecInit();
        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++;
    // Test BitVecForeach macro
    bool test_bitvec_foreach(void) {
        WriteFmt("Testing BitVecForeach macro\n");
    
        BitVec bv = BitVecInit();
        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