1 // This rule finds sequences of "unused" declerations and uses of a
2 // variable, where "unused" is defined to include only calling the
3 // equivalent of alloc, init & free functions on the variable.
7 // STRBUF_INIT, but also e.g. STRING_LIST_INIT_DUP (so no anchoring)
8 constant INIT_MACRO =~ "_INIT";
9 identifier MALLOC1 =~ "^x?[mc]alloc$";
10 identifier INIT_ASSIGN1 =~ "^get_worktrees$";
11 identifier INIT_CALL1 =~ "^[a-z_]*_init$";
12 identifier REL1 =~ "^[a-z_]*_(release|reset|clear|free)$";
13 identifier REL2 =~ "^(release|clear|free)_[a-z_]*$";
25 - T I = INIT_ASSIGN1(...);
28 <... when != \( I \| &I \)
30 - \( INIT_CALL1 \)( \( I \| &I \), ...);
32 - I = \( INIT_ASSIGN1 \)(...);
39 - \( REL1 \| REL2 \)( \( I \| &I \), ...);
41 - \( REL1 \| REL2 \)( \( &I \| I \) );
43 ... when != \( I \| &I \)