All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julia Lawall <julia.lawall@inria.fr>
To: Markus Elfring <Markus.Elfring@web.de>
Cc: cocci@systeme.lip6.fr
Subject: Re: [Cocci] Specifying conditional compilation with SmPL
Date: Tue, 26 Nov 2019 08:47:56 +0100 (CET)	[thread overview]
Message-ID: <alpine.DEB.2.21.1911260846230.2602@hadrien> (raw)
In-Reply-To: <51e6eb8b-ad70-b9b9-30da-8dd1c8bb8f82@web.de>



--- 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

  reply	other threads:[~2019-11-26  7:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-25 19:57 [Cocci] Problem writing simple patch David Frey
2019-11-25 21:10 ` Julia Lawall
2019-11-26  7:24   ` [Cocci] Specifying conditional compilation with SmPL Markus Elfring
2019-11-26  7:47     ` Julia Lawall [this message]
2019-11-26 23:46   ` [Cocci] Problem writing simple patch David Frey
2019-11-27  6:00     ` Julia Lawall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.21.1911260846230.2602@hadrien \
    --to=julia.lawall@inria.fr \
    --cc=Markus.Elfring@web.de \
    --cc=cocci@systeme.lip6.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.