On Thu, 22 Oct 2020, Mansour Moufid wrote:

> Hi,
>
> I'd like to add a statement after another within a preprocessor
> expression, but spatch adds the line without an escape (backslash).
>
> x.c:
>
>     #define X(a) x(a);
>
> (I know the above is not technically correct but it's super common.)
>
> x.cocci:
>
>     @@
>     expression e;
>     @@
>         x(e);
>     +   y(e);
>
> output:
>
>     $ spatch --sp-file x.cocci x.c
>     HANDLING: x.c
>     diff =
>     --- x.c
>     +++ /tmp/cocci-output-80658-7f90b1-x.c
>     @@ -1 +1,2 @@
>      #define X(a) x(a);
>     +y(a);
>
> I can think of two solutions, if an expression is inside a
> preprocessor statement: add a backslash before every newline, or skip
> the newline.

Indeed Coccinelle is not aware that the added code is within a #define.
Maybe it is easy to add that.

Thanks for the report.

julia
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to