Skip to contentSkip to conversation

match arbitrary argument position

cocci Jakob Koschel 1 participant 1 message Aug 16, 2022

lore
Share & tools
lore
#0 lore raw

Hi,

(resending be cause I accidently included a private email address in cc, can the duplicate be removed/rejected from the mailing list archive?)

sorry if this question is not suiting here.

I went through the documentation and most of the examples I could find, but wasn't able to easily answer my question I'm wondering about.

Basically: is there a way to match to *any* argument? E.g. make something match both of the 'x' uses in the function calls here:

int x = 5;

function_call1(x, 12, 12);

function_call2(0, x);

Based on that I was wondering if there is a way to say: match if the expression is within an expression list. So if I for instance have something like this:

@main@
type T;
parameter list P;
expression list E;
expression E1;
identifier func, func_call;
@@

  T func(P@E) {
    ...
    func_call(E1 in E)
    ...
  }

(above is not valid syntax of course)

Ideally I would like to make and get the parameters of 'func' that are used in any position as arguments in 'func_call' if that makes sense?

Any help is very much appreciated!

Thanks,
Jakob