On Mon, Jun 27, 2011 at 5:12 PM, Ajay Panyala <[email protected]> wrote: > Is the comment relevant for matching ? > > Yes, I would like to transform only the occurrence of foo(..) > with the comment above it. The patch would replace all > occurrences of foo(...) instead of replacing only the one > with a comment above it. I am assuming the number of > calls to foo(..) in the code is unknown.
So far, Coccinelle could not be used to match comments. Comments are considered to be SmPL comments. You can thus only add comments. I have tried using -//comment +//comment but it don't work either. Julia, maybe matching comments is reasonable. They are often in natural language but can also be used by annotation systems. In that case, it could be useful to match against them. Is there any problem to match them ? > > Thanks > Ajay > > On Mon, Jun 27, 2011 at 11:05 AM, Nicolas Palix <[email protected]> > wrote: >> >> Hi, >> >> Have you already tried the following semantic patch ? >> Which problem you have with it ? >> >> -------------------------------- >> @@ >> expression x,y; >> @@ >> -foo(x,y) >> +bar(x,y,z) >> ... >> foo(x,y) >> -------------------------------- >> >> Do you always have two calls to foo or could you have more/less of them ? >> Is the comment relevant for matching ? >> >> Regards. >> >> On Mon, Jun 27, 2011 at 4:21 PM, Ajay Panyala <[email protected]> wrote: >> > Hello >> > Is something like the following possible. >> > >> > Original code : >> > ... >> > // some comment >> > foo(x,y); >> > ..... >> > foo(x,y) >> > The code should be transformed after applying a patch >> > such that only the occurrence of foo(...) with the comment >> > above it should be transformed, i.e >> > The code after the transformation should look like >> > ... >> > // some comment >> > bar(x,y,z) >> > ... >> > foo(x,y) >> > The second call to foo(..) should remain untouched. >> > >> > If possible, how should a patch be specified to handle this case. >> > Thanks >> > Ajay >> > _______________________________________________ >> > Cocci mailing list >> > [email protected] >> > http://lists.diku.dk/mailman/listinfo/cocci >> > (Web access from inside DIKUs LAN only) >> > >> > >> >> >> >> -- >> Nicolas Palix >> http://sardes.inrialpes.fr/~npalix/ > > > > -- Nicolas Palix http://sardes.inrialpes.fr/~npalix/ _______________________________________________ Cocci mailing list [email protected] http://lists.diku.dk/mailman/listinfo/cocci (Web access from inside DIKUs LAN only)
