From: mquinson Date: Wed, 12 Jan 2011 07:58:23 +0000 (+0000) Subject: current version (maybe 30 or 40% done) of our spatching file X-Git-Tag: v3.6_beta2~532 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/b886b7120ce8934ec02bb0c6f898a677dd5e99c3 current version (maybe 30 or 40% done) of our spatching file git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@9396 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/src/smpi/myprintloc.cocci b/src/smpi/myprintloc.cocci new file mode 100644 index 0000000000..bea1b79f30 --- /dev/null +++ b/src/smpi/myprintloc.cocci @@ -0,0 +1,122 @@ + +@r@ +/* Matching a declaration, ie rewriting site candidate + Disqualify the candidate + ----------------- */ +type T; +position p1; +identifier id; +@@ + +T id@p1; + + + + +@funcdecl@ +# Matching a /function/ declaration. +# Disqualify the candidate +#----------------- +type T; +position r.p1; +identifier id; +@@ + T id@p1(...) {...} + + + + +@funcproto@ +# Matching a function prototype w/o body. +# Disqualify the candidate +#----------------- +type T; +position r.p1; +identifier id; +@@ + T id@p1(...); + +@localdeclaration@ +# Matching a declaration at the top level of a function. +# Disqualify the candidate +#----------------- +type T1,T2; +position r.p1; +identifier id1,id2; +@@ + +T1 id1(...) { + ... + T2 id2@p1; + ... +} + +@localinnerdeclaration@ +# The next rule is there to make sure that we are not speaking of a +# local variable declared in an inner block. I don't like it at all: +# It is redundent and gives false negative on the foreach macros that +# get often declared in the code. Example in examples/gras/spawn.c: +# +# int server() { +# ... +# xbt_dynar_foreach(chunk->primes,cursor,data) { +# char number[100]; +# ... +# } +# ... +# } +# +# Do I really need to complicate this rule further to add every macro +# that we use in our C, or can it be merged with the previous one by +# saying something like "in a function, at whatever level of nesting"? + +type T1,T2; +position r.p1; +identifier id1,id2; +expression e1,e2,e3; +@@ + +T1 id1(...) { + ... +( + for (e1;e2;e3) { ... T2 id2@p1; ... } +| + for (;e2;e3) { ... T2 id2@p1; ... } +| + for (e1;;e3) { ... T2 id2@p1; ... } +| + for (e1;e2;) { ... T2 id2@p1; ... } +| + for (e1;;) { ... T2 id2@p1; ... } +| + for (;e2;) { ... T2 id2@p1; ... } +| + for (;;e3) { ... T2 id2@p1; ... } +| + for (;;) { ... T2 id2@p1; ... } +| + while (e1) { ... T2 id2@p1; ... } +| + do { ... T2 id2@p1; ... } while (e1); +) + ... +} + + + +@script:python depends on r + && !funcdecl + && !funcproto + && !localdeclaration + && !localinnerdeclaration@ + +# This rule is only a debugging rule, to print the sites where the +# change must be applied + +p1 << r.p1; +T << r.T; +id << r.id; +@@ + +c1 = cocci.combine(id,p1) +print "1. symbol %s of type \"%s\" at %s:%s" % (id,T,c1.location.line,c1.location.column)