Release coccinelle-0.1.9-rc1
[bpt/coccinelle.git] / demos / change_all_param.cocci
diff --git a/demos/change_all_param.cocci b/demos/change_all_param.cocci
new file mode 100644 (file)
index 0000000..1f1da3f
--- /dev/null
@@ -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