On Thu, 18 Mar 2021 at 19:24, Julia Lawall <julia.law...@inria.fr> wrote:
> The ... in Coccinelle is based on control flow, so it is a bit hard to > find the return at the bottom of the function. Actually, from > Coccinelle's point of view, all returns are at the bottom of the function, > because one leaves the function after a return. Interesting, that helps me understand a little more about Coccinelle. Thanks. > You can try the following: > > @r@ > position p; > identifier f; > } > > f(...) { > <... > { .. return@p; } > ...> > } > > @@ > position p != r.p; > @@ > > - return@p; So I tried this: @r@ position p; identifier f; @@ f(...) { <... { ... return@p; } ...> } @@ position p != r.p; @@ - return@p; Which I ran as: spatch --in-place --debug --iso-file contrib/coccinelle/empty.iso \ --sp-file ./contrib/coccinelle/remove-void-return.cocci --dir fvwm With "--dir fvwm", I found that my CPU was being chewed at 100%, which I left running overnight. Some 8 hours later, spatch was still running. Presumably, Coccinelle is having an interesting time coordinating the positions? Instead, I decided to loop over the .c files which "--dir fvwm" would have done. What I found was that for some files, spatch took a few seconds, and produced no output, yet for some, spatch was still running without any result known (so I killed it). Indeed, I'm attaching a debug run of spatch to this email (cocci-debug) for one file that definitely has functions where I would expect Coccinelle to have matched a "return;" statement to be removed, but this wasn't the case. Would you be able to suggest what I might have done wrong, or if there's any additional debugging I can provide? Thanks, Thomas
cocci-debug
Description: Binary data
_______________________________________________ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci