On Tue, 3 Jan 2012, Robert Gomulka wrote:

Hi all,
a few days ago I started using Coccinelle as a tool for improving my
source code. The tool is pretty impressive, although I must admit
learning curve is quite steep for me.
Unfortunately I am unable to fully automate the checks (found in
kernel git repository and on Coccinelle web page), as they can eat
whole memory (12 GB RAM + SWAP) and/or appear to be hanging after a
few hours.

If you like, you could perhaps try to isolate the problem.

Note that if you are working with some code other than Linux, it can be good to first run eg

spatch -parse_c -dir source_directory

It might be that it is just working very hard to parse your code
because of some misunderstood macro use. Assuming it completes, it will tell you what tokens were frequently involved in parse errors. Of they are things like UNKNOWN that should just be ignored completely. In that case, you can make a file mydefs.h containing eg

#define UNKNOWN

and then pass this to spatch as -macro_file mydefs.h

You can also say -macro_file_builtins mydefs.h which causes mydefs.h to be taken into account earlier in the parsing process, but may cause some tokens to be unnecessarily skipped later on.

As for the merit. I have few C files with code like that:
for (j=0;j<CONSTANT>>2;j++)

Coccinelle gives up on that with message like:
EXN:Failure("lexical error <> detected, try -c++ option\n =File

Is it a bug? Can it be fixed in Coccinelle code?

Perhaps. This is the unpleasant thing about trying to support C++. I can try to fix it, although in the short term you could also just add some spaces, if that would not be to troubling with respect to your coding style.

julia
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)

Reply via email to