Julia Lawall wrote: >> Im now somewhat unclear on the -macro_file <> option, >> despite it helping my situation dramatically - >> Why would you not parse #included headers by default ? >> at least when theyre on the include path, like #include "perl.h" > > The default is to parse a header file that has a name that resembles that > of the file. So if you are working on video.c, it will parse video.h. At > least in the context of Linux, that is the file that is most likely to > have the definitions that are relevant to theproblem at hand. > > Parsing header files takes time. A lot of semantic patches don't need > that information. I often use the option -no_includes, when my semantic > patch is not sensitive to type information. Oh yes, parsing header files is really really slow. I'm using coccinelle on the Wine source and there I would have to recursively parse the includes to get meaningful results. But that makes my cocci scripts slow (orders of magnitude!) to the point that it becomes unpractical to use them.
> A goal of Coccinelle is to let you make transformations on macro uses as > well and to be independent of the configuration. If we just applied cpp > based on the header files that we can find, then neither of those would be > possible. Yepp, I make regular use of matching and sometimes replacing macros. > When Coccinelle has the definition of a macro, sometimes it does take that > into acount in constructing the internal representation. But in that case > the tokens involved in the use of the macro become passed, and one can't > do any transformation on them. So taking into account a macro definition > is not necessarily a desirable thing. > > These decisions were taken in the context of Linux code, where the use of > macros is mostly limited to code that stays within the syntax of C. Works for Wine too. I do have to use a macro file but that one is pretty short http://people.redhat.com/mstefani/wine/coccinelle/macros . Most of the entries in there are due to the peculiarities of the Win32 API. bye michael _______________________________________________ Cocci mailing list [email protected] http://lists.diku.dk/mailman/listinfo/cocci (Web access from inside DIKUs LAN only)
