about summary refs log tree commit diff
path: root/third_party/git/contrib/coccinelle/swap.cocci
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/git/contrib/coccinelle/swap.cocci')
-rw-r--r--third_party/git/contrib/coccinelle/swap.cocci28
1 files changed, 28 insertions, 0 deletions
diff --git a/third_party/git/contrib/coccinelle/swap.cocci b/third_party/git/contrib/coccinelle/swap.cocci
new file mode 100644
index 0000000000..a0934d1fda
--- /dev/null
+++ b/third_party/git/contrib/coccinelle/swap.cocci
@@ -0,0 +1,28 @@
+@ swap_with_declaration @
+type T;
+identifier tmp;
+T a, b;
+@@
+- T tmp = a;
++ T tmp;
++ tmp = a;
+  a = b;
+  b = tmp;
+
+@ swap @
+type T;
+T tmp, a, b;
+@@
+- tmp = a;
+- a = b;
+- b = tmp;
++ SWAP(a, b);
+
+@ extends swap @
+identifier unused;
+@@
+  {
+  ...
+- T unused;
+  ... when != unused
+  }