X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/9e3bf4095effa793b9a28be8b13352b863d2482f..7f28d0c88e047b142cfc7d5f73c19762cb27c0c5:/src/smpi/replace_globals.cocci diff --git a/src/smpi/replace_globals.cocci b/src/smpi/replace_globals.cocci index 591f27dcce..4608a2ac10 100644 --- a/src/smpi/replace_globals.cocci +++ b/src/smpi/replace_globals.cocci @@ -1,24 +1,40 @@ +// FIXME: seems like cocci has problems manipulating the declarations, at least +// when there is more than one on the same line. We already need perl to split +// up the declarations after the fact, is there another tool we can use to patch +// up and match the declarations? In that case we could consider dropping cocci, +// or just using it to alter global variable accesses. +// +// FIXME: problems +// - array declarations not properly matched...can fix, but then can't have +// multiple declarations on one line +// - does not match array initializers +// - probably won't fix structure declarations with initialization either + // Function prototype looks like variable dec, but has parentheses @funcproto@ type T; -identifier f; +identifier func; position p; @@ -T f@p(...); +T@p func(...); // Define a local variable as one whose declaration is encased in brackets @localvardecl@ type T; -identifier a; +identifier var; position p; expression E; @@ { <... ( - T a@p; +T@p +var +; | - T a@p = E; +T@p +var = E +; ) ...> } @@ -27,37 +43,49 @@ expression E; // prototype @globalvardecl@ type T; -identifier b; +identifier var; position p != { localvardecl.p, funcproto.p }; -expression E; +expression value; +expression size; @@ ( -T -+ * -b@p -+ = SMPI_INITIALIZE_GLOBAL(b, T) +T@p +- var ++ *var = SMPI_VARINIT_GLOBAL(var, T) ; | -T -+ * -b@p = -+ SMPI_INITIALIZE_AND_SET_GLOBAL(b, T, -E -+) +T@p +- var = value ++ *var = SMPI_VARINIT_GLOBAL_AND_SET(var, T, value) ; +//| +//T@p // FIXME: matches, but complains if more than one decl on a line... +//- var[size] +//+ *var[size] = SMPI_VARINIT_GLOBAL_ARRAY(T, size) +//; +//| +//T@p // FIXME: how to match initializer? +//- var[size] = { ... } +//+ *var[] = SMPI_VARINIT_GLOBAL_ARRAY_AND_SET(T, size, { ... }) +//; +//| +//T@p // FIXME: how to match initializer? how to figure out size? +//- var[] = { ... } +//+ *var[] = SMPI_VARINIT_GLOBAL_ARRAY_AND_SET(T, size, { ... }) // size = ? +//; ) @rewritelocalaccess@ -local idexpression x; -identifier globalvardecl.b; +local idexpression lvar; +identifier globalvardecl.var; @@ { <... ( -x +lvar | -+SMPI_GLOBAL_VAR_LOCAL_ACCESS( -b ++SMPI_VARGET_GLOBAL( +var +) ) ...>