[Cocci] Change function invocations argument

Julia Lawall julia.lawall at lip6.fr
Sun Dec 21 15:13:02 CET 2014



On Sun, 21 Dec 2014, Eliseo Martínez wrote:

> I’m afraid I still don’t get you.
> What I’m asking is:
> 
> Given that coccinelle understands c structure, and knows about common isomorphisms, is there an easy way so that I can instruct it to analyze every expression in my source code, and remove parentheses at every place they’re not needed? By not needed, I mean that the c expression meaning (taking into account operator precedence and the like) is the same with and without parentheses.
> 
> I’m working with a 200000 LOC codebase. So, if there’s no dependable way to do this (without false positives and the like), then I’d have to manually review every change. Feasibility of that depends on how many instances are found, which I cannot now in advance. If they are too many and I have to review them manually, then this is probably not worth the trouble.

Given the size of the code, I think it would be reasonable to consider 
safe cases as they arise.  For example,

@@
identifier x;
@@

-(
x
-)

No idea if that is useful.

The previous suggestion with x as an expression removes too much.

I thought that the following might work, ie add parentheses:

@@
@@

- x
+ 3 + 4

But testing it on:

int main () {
  return (x * (5 + 7));
}

shows that it does not.

julia


More information about the Cocci mailing list