Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
hey, figured out how to change vars to pointers without cocci complaining...
[simgrid.git] / src / smpi / replace_globals.cocci
index d64b380..d23bacf 100644 (file)
@@ -1,7 +1,6 @@
 // FIXME: problems
 // FIXME: problems
-//   - cannot change type on multiple variable declaration
+//   - does not want to match dynamic arrays...
 //   - does not match array initializers
 //   - does not match array initializers
-//   - dereferencing outside access macro? (maybe not an issue...)
 
 // Function prototype looks like variable dec, but has parentheses
 @funcproto@
 
 // Function prototype looks like variable dec, but has parentheses
 @funcproto@
@@ -38,29 +37,44 @@ var = E
 type T;
 identifier var;
 position p != { localvardecl.p, funcproto.p };
 type T;
 identifier var;
 position p != { localvardecl.p, funcproto.p };
-expression E;
+expression value;
+constant size;
 @@
 (
 T@p 
 @@
 (
 T@p 
-var
-+ = SMPI_INITIALIZE_GLOBAL(T)
+- var
++ *var = SMPI_INITIALIZE_GLOBAL(T)
+;
+|
+T@p
+- var = value 
++ *var = SMPI_INITIALIZE_AND_SET_GLOBAL(T, value)
+;
+|
+T@p
+- var[]
++ *var[] = SMPI_INITIALIZE_GLOBAL_ARRAY(T, size)
+;
+|
+T@p
+- var[size]
++ *var[] = SMPI_INITIALIZE_GLOBAL_STATIC_ARRAY(T, size)
 ;
 |
 T@p
 ;
 |
 T@p
-var = 
-- E
-+ SMPI_INITIALIZE_AND_SET_GLOBAL(T, E)
+- var[size] = { ... }
++ *var[] = SMPI_INITIALIZE_AND_SET_GLOBAL_STATIC_ARRAY(T, size)
 ;
 )
 
 @rewritelocalaccess@
 ;
 )
 
 @rewritelocalaccess@
-local idexpression x;
+local idexpression lvar;
 identifier globalvardecl.var;
 @@
 {
 <...
 (
 identifier globalvardecl.var;
 @@
 {
 <...
 (
-x
+lvar
 |
 +SMPI_GLOBAL_VAR_LOCAL_ACCESS(
 var
 |
 +SMPI_GLOBAL_VAR_LOCAL_ACCESS(
 var