[Cocci] Replacement of function calls and corresponding parameters

Julia Lawall julia at diku.dk
Sun Mar 14 16:25:06 CET 2010

On Sun, 14 Mar 2010, SF Markus Elfring wrote:

> > You can say that one rule depends on the success or failure of another, 
> > but putting eg depends on rule1 && !rule2 in the between the initial @@, 
> > next to the rule name, if any.  This is illustrated in the wiki:
> > 
> > http://cocci.ekstranet.diku.dk/wiki/doku.php?id=dependencies_between_patterns
> Can these dependencies be also applied to source code replacements (-/+ lines in
> the patch)?

The dependencies are at the rule level. But a rule might contain only a 
single change, if that is what is wanted.

> Does the description fit to changes for variables that will be 
> referenced by a function call?

I'm not sure to understand the question.  The code that is matched is the 
code that you describe.  If you want it to match something else, you have 
to describe something else.  Everything is done at the code level.

> Will the rule application be working in an execution order that will be
> different from the sequential source code?

Rules are applied in the order that they appear in the semantic patch 
file.  First the first rule is matched agains all functions.  Then any 
transformations indicated by that match are performed.  Then the second 
rule is applied to all functions.  Then any changes indicated by that 
match are performed.  And so on.  There is no iteration, ie a rule is 
never applied to code on which it has been applied previously.


More information about the Cocci mailing list