All of lore.kernel.org
 help / color / mirror / Atom feed
From: julia.lawall@lip6.fr (Julia Lawall)
To: cocci@systeme.lip6.fr
Subject: [Cocci] Embedding Meta-variables in added Comments using semantic patchesز
Date: Tue, 28 Aug 2018 03:53:32 -0700 (PDT)	[thread overview]
Message-ID: <alpine.DEB.2.21.1808280350290.2313@hadrien> (raw)
In-Reply-To: <CAKCTf_bKa6MbcvLw=0r+pjXB-TrqAKAPyXhu+vZ=0vXih7i54Q@mail.gmail.com>



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

  reply	other threads:[~2018-08-28 10:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-28  7:36 [Cocci] Embedding Meta-variables in added Comments using semantic patchesز Moustafa Mahmoud
2018-08-28 10:53 ` Julia Lawall [this message]
2018-08-29  1:52   ` Moustafa Mahmoud
2018-08-29  2:52     ` 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.1808280350290.2313@hadrien \
    --to=julia.lawall@lip6.fr \
    --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.