On Tue, 14 Jul 2015, Kris Borer wrote:

> Thank you for your help. Your patches and advice have solved my issue.

Great!  The binary operator metavariables are a recent addition, so it was
the occasion to fill in some incompletenesses in the implementation.  I
hope it works better now.

julia

>
> On Tue, Jul 14, 2015 at 1:51 PM, Julia Lawall <[email protected]> wrote:
>       Two patches are attachd that should help with this.  They can be
>       applied
>       in any order.
>
>       > bash> cat binop4.cocci
>       > @@
>       > identifier i, i2;
>       > expression E1, E2;
>       > constant c;
>       > binary operator b;
>       > @@
>       >
>       > + if( E1->i ) {
>       > +      i2 = E2;
>       > +     if (i2 b c) {
>       > - if( E1->i && (i2 = E2) b c ) {
>       >   ...
>       > - }
>       > +     }
>       > + }
>
>       Even with the patches, it is necessary to adjust the above
>       code.  The
>       problem is that with a binary operator metavariable, we don't
>       know the
>       precedence or associativity of the operator.  However we have
>       the paren
>       isomorphism that will drop extra parentheses in the semantic
>       patch
>       (without changing th structure of the AST), so you can just add
>       parentheses to the semantic patch to get the precedence or
>       associativity
>       you want.  I guess you would want ((i2 = E2) b c).
>
>       julia
>
>
>
>
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to