On Wed, 28 Dec 2011, SF Markus Elfring wrote:

You only print out information about functions that are called (function_definition.f).

A few of my difficulties with the specification of a SmPL filter pattern for a function declaration/prototype and its definition/implementation could be resolved a moment ago.

Now I am interested in further extensions for this pattern.

Both use cases can be detected separately. But I would prefer to achieve an analysis result from the execution of a single SmPL script. The consequence is that I get two SmPL rules which provide data for a file output.

But the second (OCaml or Python) script rule needs to depend on two other rules as preconditions. (A function can be implemented without a declaration before.)
http://coccinelle.lip6.fr/docs/main_grammar003.html

I would like to assign values to variables of the used scripting language from SmPL metavariables. Such assignments refer to names from previous rules usually. I'm unsure which rule name I should choose here when it can be that I need to reuse the same identifiers from the source code matches. Would you like to clarify the little difficulty with a name selection if data should be forwarded from several rules?

The only way to merge names is to have matched them in different branches of a disjunction, which unfortunately is not currently possible for a function declaration/function prototype or to match the name and store its position, and then have another rule that uses a disjunction and the position variables to merge the names. I'm not sure if this will work for you either, because something like:

@@
position first_match.p1;
position second_match.p2;
identifier x;
@@

(
x@p1
|
x@p2
)

is likely to be considered to be a pattern matching an expression that happens to be an identifier rather than matching all of the places where an identifier can occur. However, you could try it and see what happens. If it does not work, it may not be very hard to fix.

julia
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)

Reply via email to