summaryrefslogtreecommitdiff
path: root/contrib/coccinelle/swap.cocci
blob: a0934d1fdaf07e9748fb2055e4a47b029bcf8948 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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
  }