Re: [Cocci] Specifying conditional compilation with SmPL

2019-11-25 Thread Markus Elfring
> Coccinelle doesn't currently support adding ifdefs on expressions,
> only on statements.

Can the following transformation approach ever work

@adjustment2@
expression x;
@@
+#ifdef USE_F
 f
+#else
+g
+#endif
 (x);

in addition to this code variant for the semantic patch language?

@adjustment1@
expression x;
@@
+#ifdef USE_F
 f(x);
+#else
+g(x);
+#endif


Regards,
Markus
___
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci


Re: [Cocci] Specifying conditional compilation with SmPL

2019-11-25 Thread Julia Lawall



--- Please note the new email address ---


On Tue, 26 Nov 2019, Markus Elfring wrote:

> > Coccinelle doesn't currently support adding ifdefs on expressions,
> > only on statements.
>
> Can the following transformation approach ever work
>
> @adjustment2@
> expression x;
> @@
> +#ifdef USE_F
>  f
> +#else
> +g
> +#endif
>  (x);

Obviously, it what was asked for would work, this would work too.  We're
not going to make a special case to exclude expressions that are
identifiers.  But the generated code would look horrible.

The reason for putting an ifdef on an expression would be that the
expression could appear in other contexts, such as conditional tests, not
to minimize the number of characters in the file.

julia

>
> in addition to this code variant for the semantic patch language?
>
> @adjustment1@
> expression x;
> @@
> +#ifdef USE_F
>  f(x);
> +#else
> +g(x);
> +#endif
>
>
> Regards,
> Markus
>
___
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci