[PATCH] [analyzer] Do not reinitialize static globals when the function is called more than once along a path

Anna Zaks ganna at apple.com
Wed Feb 6 17:07:39 PST 2013


Attached is a new patch, which uses GDM to store the VarDecls of globals previously initialized along the path.

Thanks for the suggestion,
Anna.

On Feb 6, 2013, at 4:41 PM, Anna Zaks <ganna at apple.com> wrote:

> 
> On Feb 6, 2013, at 3:27 PM, Ted Kremenek <kremenek at apple.com> wrote:
> 
>> On Feb 6, 2013, at 3:24 PM, Ted Kremenek <kremenek at apple.com> wrote:
>> 
>>> 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.
>> 
>> … or rather Objective-C++.
>> 
>> $ cat t.mm
>> #include <stdio.h>
>> 
>> id foo(id x) {
>>   printf("%p\n", x);
>>   return x;
>> }
>> 
>> int main() {
>>   static id x = foo(x);
>> }
>> 
> 
> What are the semantics in this case? Would the value be uninitialized or 0?
> 
>> $ clang++ t.mm
>> $ ./a.out
>> 0x0
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130206/4a4f5cb9/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: staticLocals.diff
Type: application/octet-stream
Size: 4495 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130206/4a4f5cb9/attachment.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130206/4a4f5cb9/attachment-0001.html>


More information about the cfe-commits mailing list