Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
added replace globals cocci patch to repository
[simgrid.git] / src / smpi / replace_globals.cocci
1 // Function prototype looks like variable dec, but has parentheses
2 @funcproto@
3 type T;
4 identifier f;
5 position p;
6 @@
7 T f@p(...);
8
9 // Define a local variable as one whose declaration is encased in brackets
10 @localvardecl@
11 type T;
12 identifier a;
13 position p;
14 expression E;
15 @@
16 {
17 <...
18 (
19  T a@p;
20 |
21  T a@p = E;
22 )
23 ...>
24 }
25
26 // global variable is one whose declaration is neither local nor a function
27 // prototype
28 @globalvardecl@
29 type T;
30 identifier b;
31 position p != { localvardecl.p, funcproto.p };
32 expression E;
33 @@
34 (
35 -T 
36 +T*
37 b@p
38 + = SMPI_INITIALIZE_GLOBAL(T)
39 ;
40 |
41 -T 
42 +T*
43 b@p = 
44 + SMPI_INITIALIZE_AND_SET_GLOBAL(T,
45 E
46 +)
47 ;
48 )
49
50 @rewritelocalaccess@
51 local idexpression x;
52 identifier globalvardecl.b;
53 @@
54 (
55 x
56 |
57 +SMPI_GLOBAL_VAR_LOCAL_ACCESS(
58 b
59 +)
60 )