1 // FIXME: seems like cocci has problems manipulating the declarations, at least
2 // when there is more than one on the same line. We already need perl to split
3 // up the declarations after the fact, is there another tool we can use to patch
4 // up and match the declarations? In that case we could consider dropping cocci,
5 // or just using it to alter global variable accesses.
8 // - array declarations not properly matched...can fix, but then can't have
9 // multiple declarations on one line
10 // - does not match array initializers
11 // - probably won't fix structure declarations with initialization either
13 // Function prototype looks like variable dec, but has parentheses
21 // define a local variable declaration as one at some level of nesting
33 | // variable has initializer
40 // define a global variable declaration as one that is neither a function
41 // prototype nor a local variable declaration
45 position p != { funcproto.p, localvardecl.p };
52 + *var = SMPI_VARINIT_GLOBAL(var, T)
54 | // variable has initializer (not a struct or array)
57 + *var = SMPI_VARINIT_GLOBAL_AND_SET(var, T, value)
59 //| // array of specified size
60 //T@p // FIXME: matches, but complains if more than one decl on a line...
62 //+ *var[size] = SMPI_VARINIT_GLOBAL_ARRAY(T, size)
64 //| // array of specified size with initializer
65 //T@p // FIXME: how to match initializer?
66 //- var[size] = { ... }
67 //+ *var[] = SMPI_VARINIT_GLOBAL_ARRAY_AND_SET(T, size, { ... })
69 //| // array without specified size, but with initializer
70 //T@p // FIXME: how to match initializer? how to figure out size?
72 //+ *var[] = SMPI_VARINIT_GLOBAL_ARRAY_AND_SET(T, size, { ... }) // size = ?
74 //| struct with initializer?
77 // rewrite access to global variables based on name, but avoid the declaration
78 // and local variables that might have the same name
81 local idexpression lvar;
82 identifier globalvardecl.var;
94 // define a local static variable declaration as one at some level of nesting
95 // starting with the word static (exceptions?)
106 + *var = SMPI_VARINIT_STATIC(T, var)
108 | // variable has initializer (not a struct or array)
111 + *var = SMPI_VARINIT_STATIC_AND_SET(var, T, value)
118 @rewritestaticaccess@
120 identifier staticvardecl.func, staticvardecl.var;