[Cocci] Embedding Meta-variables in added Comments using semantic patchesز

Julia Lawall julia.lawall at lip6.fr
Tue Aug 28 12:53:32 CEST 2018



On Tue, 28 Aug 2018, Moustafa Mahmoud wrote:

> this semantic patch doesn't produce the required behavioir
>
> @annotate_if_conditions@
> expression ex;
> @@
>
> <+...
> + /* ex */
> if(ex){...}
> ...+>
>
>
> it produces the following 
>
>      int x =5;
>      int y =6;
>      int m =funct();
> +    /* ex */   // the required behavoir I need is  /* x */
>      if(x)
>      {
> +       /* ex */
>         if(y)
>         {
>             return 1;

Sorry, it doesn't work.  Currently the only tihng you can do is use python
to make an identifier metavariable that actually contains a comment, and
then add that metavariable where you want your comments.  By your comments
will have to have a ; after them, and are thus better made with // than
with /* */, because an identifier is not a valid statement by itself.
Instead you need an identifier followed by a semicolon.

For using python to make an identifier metavariable please see
demos/pythontococci.{c,cocci,res}.  Please write back if it is not clear.

julia


More information about the Cocci mailing list