[cfe-dev] propagating checker state for duration of a block

Richard tarka.t.otter at googlemail.com
Mon Dec 17 09:48:43 PST 2012


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?

On 17 Dec 2012, at 18:39, Jordan Rose <jordan_rose at apple.com> wrote:

> Hm. The analyzer sort of deliberately doesn't make it easy to do that, because of the (rough) equivalence of examples like this:
> 
>> if (foo) {
>>  doSomething();
>> }
> 
>> if (!foo) {
>> } else {
>>  doSomething();
>> }
> 
>> if (!foo)
>>  return;
>> doSomething();
> 
> And you don't want to just use the block ID because of this:
> 
>> if (foo) {
>>  if (bar) {
>>    doSomething();
>>  } else {
>>    doSomethingElse();
>>  }
>> }
> 
> 
> For what it's worth, clearing out the state is generally just an optimization. If you don't do it, the analyzer will just continue analyzing the rest of the program along both paths (where the branch was true and where it was false).
> 
> What are you actually trying to do?
> 
> Jordan
> 
> 
> On Dec 17, 2012, at 8:55 , Richard <tarka.t.otter at googlemail.com> wrote:
> 
>> hello
>> 
>> i am trying to write a checker that needs to propagate state for the duration of the branch blocks. can anyone suggest a good pattern for this? i can easily set state in the checkBranchCondition callback, but there does not seem to be any way to know when the branch block is complete, so it is not possible to know when to clear the state. ideally there would be a checkBlockEdge callback or something similar, then i could associate the state with the block id and it would be simple to know when to clear it. i cannot use the branch condition symbol as the state key as it will be purged as soon as the block starts.
>> 
>> is there already a way to do this that i am missing?
>> 
>> thanks
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
> 





More information about the cfe-dev mailing list