3 /* Matching a declaration, ie rewriting site candidate
4 Disqualify the candidate
17 # Matching a /function/ declaration.
18 # Disqualify the candidate
30 # Matching a function prototype w/o body.
31 # Disqualify the candidate
40 # Matching a declaration at the top level of a function.
41 # Disqualify the candidate
54 @localinnerdeclaration@
55 # The next rule is there to make sure that we are not speaking of a
56 # local variable declared in an inner block. I don't like it at all:
57 # It is redundent and gives false negative on the foreach macros that
58 # get often declared in the code. Example in examples/gras/spawn.c:
62 # xbt_dynar_foreach(chunk->primes,cursor,data) {
69 # Do I really need to complicate this rule further to add every macro
70 # that we use in our C, or can it be merged with the previous one by
71 # saying something like "in a function, at whatever level of nesting"?
82 for (e1;e2;e3) { ... T2 id2@p1; ... }
84 for (;e2;e3) { ... T2 id2@p1; ... }
86 for (e1;;e3) { ... T2 id2@p1; ... }
88 for (e1;e2;) { ... T2 id2@p1; ... }
90 for (e1;;) { ... T2 id2@p1; ... }
92 for (;e2;) { ... T2 id2@p1; ... }
94 for (;;e3) { ... T2 id2@p1; ... }
96 for (;;) { ... T2 id2@p1; ... }
98 while (e1) { ... T2 id2@p1; ... }
100 do { ... T2 id2@p1; ... } while (e1);
107 @script:python depends on r
111 && !localinnerdeclaration@
113 # This rule is only a debugging rule, to print the sites where the
114 # change must be applied
121 c1 = cocci.combine(id,p1)
122 print "1. symbol %s of type \"%s\" at %s:%s" % (id,T,c1.location.line,c1.location.column)