From: Jerome Glisse <jglisse@redhat.com>
To: Julia Lawall <julia.lawall@lip6.fr>
Cc: cocci@systeme.lip6.fr
Subject: Re: [Cocci] Add code after local variable declarations ?
Date: Wed, 17 Apr 2019 10:14:30 -0400 [thread overview]
Message-ID: <20190417141429.GA3229@redhat.com> (raw)
In-Reply-To: <alpine.DEB.2.21.1904170712320.2612@hadrien>
On Wed, Apr 17, 2019 at 07:14:29AM +0200, Julia Lawall wrote:
>
>
> On Tue, 16 Apr 2019, Jerome Glisse wrote:
>
> > I would like to add code after local variable declaration but there
> > is nothing particular to match there for me. Roughly i want to do:
> >
> > void FooFun(..., struct fooicareabout *identifier, ...)
> > {
> > // bunch of local variable
> >
> > // I want to add code here after all local variables
> > }
>
> @@
> statement S,S1;
> @@
>
> foo(...) {
> ... when != S
> + added code
> S1
> ...
> }
>
> A declaration doesn't match S.
Oh cool did not think of that thanks. What happens if some of the
declaration also have initializer that are statement ie for instance:
foobar(int a, int b, int c, struct fooicareabout *id)
{
int toto = funbar(a, b);
int k, l, m;
...
}
>
> >
> > The thing i match on is one of the function argument. So is that do-
> > able ? If so any pointer on how to do this would be much appreciated.
>
> I'm not sure what you are trying to do here. You can certainly make a
> pattern for your parameters like you have shown in the example. Do you
> mean that you want to go find the argument value at the call site?
No i want to add some code to _all_ function that have a specific
structure as one of their argument. Thus i match on the function
parameter list for the struct i am interested in and then after
all the declaration i add a code snippet.
Cheers,
Jérôme
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci
next prev parent reply other threads:[~2019-04-17 14:15 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-16 22:11 [Cocci] Add code after local variable declarations ? Jerome Glisse
2019-04-17 5:14 ` Julia Lawall
2019-04-17 9:10 ` [Cocci] Add code after local variable declarations? Markus Elfring
2019-04-17 9:12 ` Julia Lawall
2019-04-17 9:42 ` Markus Elfring
2019-04-17 9:42 ` Markus Elfring
2019-04-17 14:14 ` Jerome Glisse [this message]
2019-04-17 14:32 ` [Cocci] Add code after local variable declarations ? Julia Lawall
2019-04-17 16:42 ` [Cocci] Add code after local variable declarations? Markus Elfring
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=20190417141429.GA3229@redhat.com \
--to=jglisse@redhat.com \
--cc=cocci@systeme.lip6.fr \
--cc=julia.lawall@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).