[Cocci] if else not matching

Derek M Jones derek at knosof.co.uk
Tue Jun 30 19:58:26 CEST 2009


Julia,

> Thanks for the report.  The problem is that p_2_ie for some reason does 
> not get bound.  I suspect that this is due to some over-aggressive 
> optimization.  I will look into it.

Glad to know that it is not me.

I did try removing the p_2_ie at one stage and still did not get a
match, although there was a warning about a meta variable
not being used.

I have just removed the third line from the following:
script:python @ expr_1_ie << if_else_1.E_1_ie;
                 loc_1_ie << if_else_1.p_1_ie;
                 loc_2_ie << if_else_1.p_2_ie;

and a match now occurs, along with a later warning that
loc_2_ie is not defined.

So there also appears to be some interaction with matching
and execution of a script.

> You can see the problem with the -debug option.  Only the position for the 
> if and the variable for the test expression are mentioned in the 
> environment that is the result of the match:
> 
> -----------------------------------------------------------------------
> if_else_1 = 
> -----------------------------------------------------------------------
> dependencies for rule if_else_1 satisfied:
> binding in = []
> binding relevant in = []
>      transformation info is empty
>      binding out = [E_1_ie --> x2;
>                    p_1_ie --> poss[(tests/ife.c,f,(3,0),(3,2))]]
> 
> julia
> 
> 
> 
>> @ if_else_1
>> disable neg_if
>> @
>> expression E_1_ie;
>> statement S_1_ie, S_2_ie;
>> position p_1_ie, p_2_ie;
>> @@
>> if at p_1_ie (E_1_ie)
>>    S_1_ie
>> else at p_2_ie
>>    S_2_ie
>> @
>>
>> script:python @ expr_1_ie << if_else_1.E_1_ie;
>>                 loc_1_ie << if_else_1.p_1_ie;
>>                 loc_2_ie << if_else_1.p_2_ie;
>>               @@
>> print "--- ifelse"
>> print loc_1_ie[0].line, " ", loc_1_ie[0].column, " ", expr_1_ie
>> print loc_2_ie[0].line, " ", loc_2_ie[0].column
>>
>> the C input:
>>
>> void f(void)
>> {
>> if (x2)
>>    w++;
>> else
>>    z--;
>> }
>>
>> -- 
>> Derek M. Jones                         tel: +44 (0) 1252 520 667
>> Knowledge Software Ltd                 mailto:derek at knosof.co.uk
>> Source code analysis                   http://www.knosof.co.uk
>> _______________________________________________
>> Cocci mailing list
>> Cocci at diku.dk
>> http://lists.diku.dk/mailman/listinfo/cocci
>> (Web access from inside DIKUs LAN only)
>>
>>
> 

-- 
Derek M. Jones                         tel: +44 (0) 1252 520 667
Knowledge Software Ltd                 mailto:derek at knosof.co.uk
Source code analysis                   http://www.knosof.co.uk


More information about the Cocci mailing list