Here is a not very satisfactory solution:
@r@
expression E;
position p;
@@
- return@p E;
+ RETURN(E);
@script:python@
p << r.p;
@@
print p[0].current_element
@@
identifier f;
@@
- f(...) { ... }
----------------------------------
The idea is to turn all of the returns into something less dangerous, and
then remove the complete function in which there is no longer any dead
code. I guess you don't really want to remove all functions, but only
functions with eg a particular name. The python code in the middle shows
how you can get the name of function containing each return. You would
want to match it, then check the name using python, using
cocci.include_match false if it is unsuitable, and then have another rule
after the python one that actually does the removal.
The problem is that ... is control-flow path based, and there is no
control-flow path that leads to dead code. So it does not seem easy to
address this particular case more transparently.
julia
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)