[Cocci] Change function invocations argument

Eliseo Martínez eliseomarmol at gmail.com
Sun Dec 21 13:24:40 CET 2014


That’s right. I wanted to remove external parentheses, which wasn’t done if employing only e2/e3.
I hadn’t realized using (e2)/(e3) would take care of both cases (with/without parentheses), though.

BTW, is there an easy way to remove **all** unneeded parentheses, project wide?

Thanks.
> On 21 Dec 2014, at 13:04, Julia Lawall <julia.lawall at lip6.fr> wrote:
> 
> 
> 
> On Sun, 21 Dec 2014, SF Markus Elfring wrote:
> 
>>> @@ typedef long_u, uintmax_t; expression e1, e2, e3; @@
>>> 
>>>    put_bytes(
>>>        e1,
>>> (
>>> -       (long_u)(e2)
>>> |
>>> -       (long_u)e2
>>> )
>>> +       (uintmax_t)e2
>>>        ,
>>> (
>>> -       (int)(e3)
>>> +       (unsigned int)e3
>>> |
>>> -       (int)e3
>>> +       (unsigned int)e3
>>> |
>>>        e3
>>> )
>>>    )
>> 
>> Can it be that you need to fiddle with SmPL disjunctions a bit less here
>> because the metavariable type (or an isomorphism) will take care for
>> additional parentheses around the affected expressions?
>> 
>> How do you think about the applicability of the following approach?
>> 
>> @parameter_cast_replacement@
>> expression e1, e2, e3;
>> typedef long_u, uintmax_t;
>> @@
>> put_bytes(e1,
>> -          (long_u)
>> +          (uintmax_t)
>>           e2,
>> (
>> -          (int)
>> +          (unsigned int)
>>           e3
>> |
>>           e3
>> )
>>          )
> 
> It looks like Eliseo wants to get rid of the parentheses, which your 
> approach does not do.  On the other hand, Markus is right that 
> 
>>> (
>>> -       (long_u)(e2)
>>> |
>>> -       (long_u)e2
>>> )
> 
> could be just
> 
> -       (long_u)(e2)
> 
> and an isomorphism will allow it to match the case where the parentheses 
> are already removed as well.
> 
> julia
> 
> 
>> 
>> Regards,
>> Markus
>> _______________________________________________
>> Cocci mailing list
>> Cocci at systeme.lip6.fr
>> https://systeme.lip6.fr/mailman/listinfo/cocci



More information about the Cocci mailing list