On Fri, 24 May 2019, Timur Tabi wrote:

> @@
> identifier func;
> @@
> func(...) {
> <+...
>      .... stuff
> +   goto func_exit;
> +}
> ...+>
> }
>
> So if I have this code:
>
> void myfunc(int x)
> {
> }
>
> I want it to look like this:
>
> void myfunc(int x)
> {
>     goto myfunc_exit;
> }
>
> My problem is that cocci takes "func_exit" literally.  I tried
> func##_exit, but that didn't work.  How do I make this work?

Python.  You need one rule to collect the func name, then a python rule to
create the new identifier you want, and then a third rule to do the
transformation.  See coccinelle/demos/pythontococci.cocci

julia
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to