X-Git-Url: https://git.hcoop.net/bpt/coccinelle.git/blobdiff_plain/708f4980a90e2a254d7863f875888e9f5c6db0b3..978fd7e56b141f7e4c8930acdbf0a806489e63a5:/demos/change_all_param.cocci diff --git a/demos/change_all_param.cocci b/demos/change_all_param.cocci new file mode 100644 index 0000000..1f1da3f --- /dev/null +++ b/demos/change_all_param.cocci @@ -0,0 +1,69 @@ +// author: Pad. Example based on discussions with Nicholas Mc Guire. + +// call site +@ r1 @ +identifier fn; +expression ret; +@@ + +- ret = + fn( ++ ret, + ...) + + +@ r2 @ +identifier r1.fn; +expression e; +@@ + + +fn (..., +- e ++ &e + ,...) + + +// definition site +@@ +type T; +identifier r1.fn; +@@ + +- T ++ void + fn( ++ T ret, + ...) +{ +... +} + + +@ rparam @ +identifier r1.fn; +type T; +identifier x; +@@ + +fn(..., +- T x ++ T *x + ,...) +{ +... +} + +// weird, if I inline this rule in previous rule it does +// not work +@@ +identifier r1.fn; +identifier rparam.x; +@@ +fn(...) +{ +<... +- x ++ *x +...> +} \ No newline at end of file