[cfe-dev] propagating checker state for duration of a block
Jordan Rose
jordan_rose at apple.com
Mon Dec 17 09:52:17 PST 2012
On Dec 17, 2012, at 9:48 , Richard <tarka.t.otter at googlemail.com> wrote:
> well, the idea is to set state if a branch condition is checking for availability, eg
>
> if ([foo respondsToSelector:@selector(onlyAvailableInIOS6:)]) {
> // set availability version
> doIOS6Stuff();
> else {
> // issue a warning here
> doIOS6Stuff();
> }
>
> so a warning can be issued if there is are any methods used newer than the minimum deployment target that are being used without checking for their availability.
>
> clearly here the state has to be cleared at the end of if {}, otherwise the checker will just assume that all successive calls in the graph have checked for availability already. what would you suggest as a good way of clearing the state once the ifstmt is complete?
Well, no, it doesn't have to be. If I write this:
> if ([foo respondsToSelector:@selector(onlyAvailableInIOS6:)]) {
> doIOS6Stuff();
> }
>
> doMoreIOS6Stuff();
The call to 'doMoreIOS6Stuff' will be analyzed twice: once along the true-path from the if-statement, and once along the false-path. So you'd still get a warning on the false path, even though the true path would be quiet. And this is actually what you want for the early return case:
> if (![foo respondsToSelector:@selector(onlyAvailableInIOS6:)])
> return;
> doIOS6Stuff();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20121217/d92292c8/attachment.html>
More information about the cfe-dev
mailing list