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
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to