Hello,

The following small script for the semantic patch language
can point various source code places out for further considerations.

@replacement@
expression x;
identifier rc;
@@
-rc = x;
 return
-       rc
+       x
 ;

@deletion@
identifier replacement.rc;
type t;
@@
-t rc;
 ... when != rc


Unfortunately, this source code transformation approach seems to be
too generic. Places will be suggested for a change which should
be kept untouched.

The replacement of assignments should be restricted to local variables.
I guess that the metavariable type “local idexpression” should work
for this purpose.
But I got the impression that its use triggers design challenges
for the removal of a variable by an inherited metavariable in the
second SmPL rule.
Which adjustments should be taken better into account for this use case?

Regards,
Markus
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to