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: Devin Coughlin <email@hidden>
- Date: Tue, 15 Mar 2016 17:53:46 -0700
On Mar 15, 2016, at 1:27 PM, Wim Lewis < email@hidden> wrote:
On Mar 15, 2016, at 12:14 PM, Jens Alfke < email@hidden> wrote: I added the assertion to try to make the warning go away, but it doesn’t go away. However, if I move the assert call down to below the NSLog, the warning goes away. It looks as though the analyzer believes that calling NSLog can change _foo to nil somehow.
It might be the assert() that is bringing the warning to light. If you have code that considers the possibility of nil, then the analyzer assumes that it could be nil. If your code doesn't consider the possibility of nil, then the analyzer frequently won't, either.
You can get false positives like this if you use custom assertion macros in your project. In this case you would need to annotate the assertion handler (the part of the assertion macro that aborts when the check fails) with __attribute__((analyzer_noreturn)). This tells the analyzer to only consider flows on which the assertion holds. There are more details on how to do this at < http://clang-analyzer.llvm.org/annotations.html#custom_assertions>.
Devin |
_______________________________________________
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