Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add a specific file to manage tracing in SimDag
[simgrid.git] / src / smpi / myprintloc.cocci
1
2 @r@
3 /* Matching a declaration, ie rewriting site candidate 
4    Disqualify the candidate
5    ----------------- */
6 type T;
7 position p1;
8 identifier id;
9 @@
10
11 T id@p1;
12
13
14
15
16 @funcdecl@
17 # Matching a /function/ declaration. 
18 # Disqualify the candidate
19 #-----------------
20 type T;
21 position r.p1;
22 identifier id;
23 @@
24  T id@p1(...) {...}
25
26
27
28
29 @funcproto@
30 # Matching a function prototype w/o body. 
31 # Disqualify the candidate
32 #-----------------
33 type T;
34 position r.p1;
35 identifier id;
36 @@
37  T id@p1(...);
38
39 @localdeclaration@
40 # Matching a declaration at the top level of a function. 
41 # Disqualify the candidate
42 #-----------------
43 type T1,T2;
44 position r.p1;
45 identifier id1,id2;
46 @@
47
48 T1 id1(...) {
49   ...
50   T2 id2@p1;
51   ...
52 }
53
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:
59
60 # int server() {
61 #   ...
62 #   xbt_dynar_foreach(chunk->primes,cursor,data) {
63 #     char number[100];
64 #     ...
65 #   }
66 #   ...
67 # } 
68 #
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"?
72
73 type T1,T2;
74 position r.p1;
75 identifier id1,id2;
76 expression e1,e2,e3;
77 @@
78
79 T1 id1(...) {
80   ...
81
82   for (e1;e2;e3) { ... T2 id2@p1; ... }
83
84   for (;e2;e3) { ... T2 id2@p1; ... }
85
86   for (e1;;e3) { ... T2 id2@p1; ... }
87
88   for (e1;e2;) { ... T2 id2@p1; ... }
89
90   for (e1;;) { ... T2 id2@p1; ... }
91
92   for (;e2;) { ... T2 id2@p1; ... }
93
94   for (;;e3) { ... T2 id2@p1; ... }
95
96   for (;;) { ... T2 id2@p1; ... }
97
98   while (e1) { ... T2 id2@p1; ... }
99
100   do { ... T2 id2@p1; ... } while (e1);
101 )
102   ...
103 }
104
105
106
107 @script:python depends on r 
108                           && !funcdecl 
109                           && !funcproto 
110                           && !localdeclaration 
111                           && !localinnerdeclaration@
112
113 # This rule is only a debugging rule, to print the sites where the
114 # change must be applied
115
116 p1 << r.p1;
117 T  << r.T;
118 id << r.id;
119 @@
120
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)