This patch makes sure that we do not reinitialize static globals when the 
function is called more than once along a path. The motivation is code with 
initialization patterns that rely on 2 static variables, where one of them has 
an initializer while the other does not. Like the ObjC example below.

Currently, we reset the static variables with initializers on every visit to 
the function along a path. The solution might be a bit hacky as we check if the 
region has been stored something other than a LazyCompoundVal to find out if 
the static variable has been assigned to previously.

Anna.

void Function1(void);
void Function2(void);
NSMutableDictionary * aaa();

void Function1(void)
{
    static dispatch_once_t predicate;
    static NSMutableDictionary *foo = 0;
        if (!predicate) {
            predicate = 1;
                foo = aaa();
        }
    @synchronized(foo) {
            Function2();
    }
}

void Function2(void)
{
    // COMMENT OUT THE NEXT LINE TO REMOVE ANALYZER WARNING
    Function1();
}

Attachment: staticLocals.diff
Description: Binary data

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to