On 08/09/2015 20:35, Markus Armbruster wrote:
>> > Having not used Coccinelle yet, what happens if any of these functions
>> > become desynchronized ?
> Coccinelle transforms C to C.  Problem: if you parse C the normal way
> (first run preprocessor, then the parser proper), you have to unparse
> and unpreprocess at the end to get a useful result.  Unparsing is easy,
> but unpreprocessing is hard.
> 
> Instead, Coccinelle tries to parse *unpreprocessed* C.  Works most of
> the time, because most uses of function-like macros can be treated as if
> they were function calls, and most uses of object-like macros can be
> treated as if they were values.
> 
> When it doesn't work, Coccinelle needs to resort to magic and / or skip
> over some code it can't decipher.  The latter is undesirable, because if
> the skipped code contains something we'd like to transform, we won't.
> 
> Part of the magic is treating "bad" macros specially.  --macro-file
> helps with that part: macros defined there are "bad".  Sorry, I can't
> really explain it, -EMAGIC.  /usr/share/coccinelle/standard.h is used by
> default.
> 
> So what happens when the this file gets out of sync?  Worst case is
> Coccinelle misses a pattern it could find if it was in sync.
> 
> Provided the macro file makes sense initially, a moderately bit-rotten
> version is still almost certainly better than nothing.

Great answer.  I'll only add that exactly the same issue happens with
the Coverity model.

Paolo

Reply via email to