I think you want to match on the name of each defined function and then have another rule that sees if the function is called in a certain way. If it is called in a certain way (depends on xxx where xxx is the name of the rule that finds the call) then you print out one thing. If it is not called in that way (depends on !xxx) then you print out something else. You need a separate python rule for each case.

On Tue, 27 Dec 2011, SF Markus Elfring wrote:

The function prototypes for example are also not useful.

The three function declarations are essential for this test.

But the prototypes are not. In general in C, I don't see the need to write eg

int foo(int);
int foo(int x) { return 1; }

julia

@function_declaration@
identifier f;
position p;
@@
f@p(...);

All of your rules refer to function_definition.f.

I did not interpret the shown SmPL wording in this way so far.


function_definition.f is only bound when a function is called.
In the case of python, if any of the inherited variables is not bound,
then the python code is not executed. This is the case even if the unbound
variable is not mentioned in the python code.

Thanks for your explanation.


Your rule only prints information about functions that are called.

I would like to change that for my SmPL filter pattern.


I don't know what criteria you want touse to cause my_addition to be printed.

An extended filter pattern should show the use cases in a tabular file format when a function was declared and where it was defined/implemented.

Regards,
Markus

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

Reply via email to