Re: Static analyzer making unwarranted assumptions about ivars
Re: Static analyzer making unwarranted assumptions about ivars
- Subject: Re: Static analyzer making unwarranted assumptions about ivars
- From: Ken Thomases <email@hidden>
- Date: Tue, 15 Mar 2016 12:51:58 -0500
On Mar 15, 2016, at 12:30 PM, Jens Alfke <email@hidden> wrote:
>
> I’ve got two inexplicable static analyzer warnings, which hinge on the analyzer believing that an Obj-C ivar being nil. (In one case it's passed to a parameter declared nonnull, in the other it’s tested for nil in an ‘if’, and the bad situation happens inside the body of the ‘if’.) But in neither case does the analyzer know that the ivar is nil.
>
> What kinds of assumptions does the static analyzer make about ivars? It can’t just assume that any ivar may be nil on entry to any method, because that would produce enormous numbers of false positives.
You're right about that. However, if the code being analyzed explicitly tests if the variable is nil, then that introduces the possibility that it might be, so the analyzer considers what happens if it is. In other words, some code may analyze as fine but then you add "if (someVar) {}" or similar to it and now the analyzer reports problems precisely because you've raised the possibility of the variable being nil.
Not sure about the other case.
Regards,
Ken
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden