summaryrefslogtreecommitdiffstats
path: root/tools/coccinelle/strvec.cocci
blob: 64edb09f1c76fddc9ef8a94f8d2b412dd2d8681d (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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
@@
type T;
identifier i;
expression dst;
struct strvec *src_ptr;
struct strvec src_arr;
@@
(
- for (T i = 0; i < src_ptr->nr; i++) { strvec_push(dst, src_ptr->v[i]); }
+ strvec_pushv(dst, src_ptr->v);
|
- for (T i = 0; i < src_arr.nr; i++) { strvec_push(dst, src_arr.v[i]); }
+ strvec_pushv(dst, src_arr.v);
)

@ separate_loop_index @
type T;
identifier i;
expression dst;
struct strvec *src_ptr;
struct strvec src_arr;
@@
  T i;
  ...
(
- for (i = 0; i < src_ptr->nr; i++) { strvec_push(dst, src_ptr->v[i]); }
+ strvec_pushv(dst, src_ptr->v);
|
- for (i = 0; i < src_arr.nr; i++) { strvec_push(dst, src_arr.v[i]); }
+ strvec_pushv(dst, src_arr.v);
)

@ unused_loop_index extends separate_loop_index @
@@
  {
  ...
- T i;
  ... when != i
  }

@ depends on unused_loop_index @
@@
  if (...)
- {
  strvec_pushv(...);
- }