Sometimes is it useful to match a function parameter in an unknown position and then match the arguments at call sites that correspond to that parameter. The following semantic patch illustrates how to do this:

@r@
identifier fn, x;
parameter list[n] P;
@@

fn(P, long x,...) { ... }

@@
identifier r.fn;
expression list[r.n] E;
@@

fn(E,
-    atoi
+    atol
         (...),...)

It is of course possible to go the other way, and match first an argument and then the parameter in the corresponding position, or any other combination.

 
parameter_list_matching.txt · Last modified: 2009/05/31 22:19 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki