On Sat, 10 Dec 2011, SF Markus Elfring wrote:
Could you give some more context (or just resend the email
that this is referring to)?
I hope that you do not mind the following repetition. Would you like to reply
to any more requests from the previous weekend?
-------- Original Message --------
Date: Sat, 03 Dec 2011 15:15:41 +0100
Anyway, you may also want to consider cases where the result of the
function is assigned to a variable that is unused.
I would like to extend the suggested example. But I see the next challenges
besides variable assignment chains.
How can the following use cases be efficiently specified for the semantic
patch
language?
A function return value or a corresponding variable is not used in ...
1. ... a conditional expression.
2. ... a function call parameter.
I'm not sure how you mean to combine these. The return value is used in
neither 1 nor 2?
In your solution, there is not enough connection between the rules.
identifier y is just a name. It can match anywhere in the program, not
necessarily in the places that follow your assignment.
I think you would want something like the following:
@r forall@
position p;
local idexpression x;
expression f,g,e;
statement S1,S2;
@@
x@p = f(...);
... when != if (<+...x...+>) S1 else S2
when != g(...,(<+...x...+>),...)
when strict
?x = e
@@
position p != r.p;
local idexpression x;
expression f;
@@
*x@p = f(...);
Rule r checks that there is no use on any execution path. If you want to
signal cases where there exists one execution path with no use, then
remove the forall and the when strict. You may want to add more cases to
the list of whens, to represent other legitimate uses.
I'm not sure what you want to do with macros. I guess a macro call could
look like a use of x in an argument, but the macro could do something
else. But I'm not sure why you would want to distinguish this from a
function call that does something else with the value. When you pass a
value to a function, you don't know if it is going to test it.
julia
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)