Re: [Cocci] Add code after local variable declarations?

2019-04-17 Thread Markus Elfring
> 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 This source code search approach is generally fine. > and then after all the declaration i add a code

Re: [Cocci] Add code after local variable declarations ?

2019-04-17 Thread Julia Lawall
On Wed, 17 Apr 2019, Jerome Glisse wrote: > 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.

Re: [Cocci] Add code after local variable declarations ?

2019-04-17 Thread Jerome Glisse
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

Re: [Cocci] Add code after local variable declarations?

2019-04-17 Thread Markus Elfring
>> Would you like to add any source code only after a variable declaration > > Coccinelle doesn't allow this. It has no way of knowing whether other > declarations come afterwards, I suggest to reconsider this quick response. Are there approximations supported for such a source code search

Re: [Cocci] Add code after local variable declarations?

2019-04-17 Thread Markus Elfring
>> Would you like to add any source code only after a variable declaration > > Coccinelle doesn't allow this. It has no way of knowing whether other > declarations come afterwards, I suggest to reconsider this quick response. Are there approximations supported for such a source code search

Re: [Cocci] Add code after local variable declarations?

2019-04-17 Thread Markus Elfring
> @@ > statement S,S1; > @@ > > foo(...) { > ... when != S > + added code > S1 > ... > } > > A declaration doesn't match S. Can this information trigger additional considerations for the handling of variable definitions? Would you like to add any source code only after a variable

Re: [Cocci] Working with backreferences in SmPL scripts?

2019-04-17 Thread Markus Elfring
> A metavariable is always bound to the same value within a given > control-flow path. Thanks for this information. > I have no idea what you are trying to get at with this example. Some goals can match to my use case description. * Is another nice refactoring application demonstrated for

Re: [Cocci] Working with backreferences in SmPL scripts?

2019-04-17 Thread Julia Lawall
On Wed, 17 Apr 2019, Markus Elfring wrote: > Hello, > > I have tried another small SmPL script out. > > > @replacement@ > expression ex; > identifier var; > @@ > var > - = var + > + += > ex > > > elfring@Sonne:~/Projekte/Coccinelle/Probe> spatch simplify_addition1.cocci >

[Cocci] Working with backreferences in SmPL scripts?

2019-04-17 Thread Markus Elfring
Hello, I have tried another small SmPL script out. @replacement@ expression ex; identifier var; @@ var - = var + + += ex elfring@Sonne:~/Projekte/Coccinelle/Probe> spatch simplify_addition1.cocci Test_increment1.c … @@ -1,6 +1,6 @@ int main(void) { int counter = 3;