All of lore.kernel.org
 help / color / mirror / Atom feed
From: sebald.ziegler.cocci@ikolus.de (sebald.ziegler.cocci at ikolus.de)
To: cocci@systeme.lip6.fr
Subject: [Cocci] Problems with adding code after macro definitions
Date: Wed, 22 Mar 2017 15:28:41 +0100	[thread overview]
Message-ID: <8873570.AgTeYTv5Np@detux> (raw)

Hi,

I try to use coccinelle for some kind of Macro instrumentation.
One important step is to define a wrapper for a macro after the original macro definition.
This is attempted in the rule: macro_wrapper_int_MAX_int_int
But I cannot get it to work - see the ???.
All other rules work as intended.

So the question is: What is the right way to specify the macro definition after which something should be added?
Is it at all possible to only use the name of the macro and some wildcard (as opposed to using macro name and its definition).

@script:python macros@
macro_wrapper_int_MAX_int_int_str;
@@
coccinelle.macro_wrapper_int_MAX_int_int_str = '({printf("MAX\\n"); MAX(p0, p1); })'

@macro_wrapper_int_MAX_int_int@
identifier macros.macro_wrapper_int_MAX_int_int_str;
@@
#define MAX(x,y) ???
+#define macro_wrapper_int_MAX_int_int(p0, p1) macro_wrapper_int_MAX_int_int_str

@macro_replacer_macro_wrapper_int_MAX_int_int@
int P0;
int P1;
@@
-MAX(P0, P1)
+macro_wrapper_int_MAX_int_int(P0, P1)

C program:
$ cat test.c
#define MAX(x,y) ((x>y)?x:y)
#include <stdio.h>
int main(int argc, char** argv) {
        int a=5;
        int b=7;
        int d=MAX(a,b+4);
        return d;
}

Any hints and information is greatly appreciated!

Thanks,
Sebald

             reply	other threads:[~2017-03-22 14:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-22 14:28 sebald.ziegler.cocci at ikolus.de [this message]
2017-03-22 14:46 ` [Cocci] Problems with adding code after macro definitions 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=8873570.AgTeYTv5Np@detux \
    --to=sebald.ziegler.cocci@ikolus.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.