[PATCH] [analyzer] Do not reinitialize static globals when the function is called more than once along a path
kremenek at apple.com
Wed Feb 6 15:24:48 PST 2013
On Feb 6, 2013, at 3:21 PM, Ted Kremenek <kremenek at apple.com> wrote:
> On Feb 6, 2013, at 3:15 PM, Anna Zaks <ganna at apple.com> wrote:
>> 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.
> Hi Anna,
> Why not just record the initialization in a side-table in the GDM? That seems a lot cleaner. This patch seems to rely on all the other pieces working correctly. It also doesn't seem correct. A static variable for an Objective-C pointer is guaranteed to be a valid value (it is zero-initialized), even if we haven't visited the initializer yet. For example:
> static id x; // this is always zero-initialized
Put another way, this patch seems to rely on the value of a variable being "uninitialized" to indicate whether or not the initializer has been executed. That's not a valid assumption. For example:
static id x = foo(x);
is "okay" in Objective-C.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-commits