From: julia.lawall@lip6.fr (Julia Lawall)
To: cocci@systeme.lip6.fr
Subject: [Cocci] Adding missing parameter to function if missing
Date: Wed, 6 Jul 2016 18:23:02 +0200 (CEST) [thread overview]
Message-ID: <alpine.DEB.2.10.1607061819400.3168@hadrien> (raw)
In-Reply-To: <bda6f254dbe94ad28468d5de4b6c3a17@vprd-opci0018.b-com.local>
> @ test depends on !fn_with_user@
> identifier fn_with_user.fn;
> parameter list pl;
> expression E;
> @@
>
> fn(
> + my_type *foo,
> pl) {
> <+...
> bar(foo, E);
> ...+>
> }
This rule is contradictory. You say that the rule fn_with_user should not
have matched, but you want to match the identifier fn_with_user.fn.
Instead, you should match fn first, then have one rule that matches the
case you don't want, and then finally the case that you do want:
@barfn@
identifier fn;
@@
fn(...) {
<+...
bar(...);
...+>
}
@fn_with_user@
identifier barfn.fn, foo;
typedef my_type;
parameter list pl;
expression E;
@@
fn(my_type *foo, pl) {
<+...
bar(foo, E);
...+>
}
@ test depends on !fn_with_user@
identifier barfn.fn;
parameter list pl;
expression E;
@@
fn(
+ my_type *foo,
pl) {
<+...
bar(foo, E);
...+>
}
When you match barfn, you create an environment for each possible value of
fn. This is then passed through the next two rules, where it records
whether the rule fn_with_user matches. There is a separate environment for
each match of barfn.
julia
next prev parent reply other threads:[~2016-07-06 16:23 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-06 13:54 [Cocci] Adding missing parameter to function if missing Frédéric LEROY (ext)
2016-07-06 16:23 ` Julia Lawall [this message]
2016-07-07 12:18 ` Frédéric LEROY (ext)
2016-07-07 16:14 ` [Cocci] Adding " SF Markus Elfring
2016-07-08 10:46 ` Frédéric LEROY (ext)
2016-07-07 17:09 ` [Cocci] Adding missing " Julia Lawall
2016-07-06 16:50 ` [Cocci] Adding " SF Markus Elfring
2016-07-07 11:54 ` Frédéric LEROY (ext)
2016-07-07 15:43 ` SF Markus Elfring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.DEB.2.10.1607061819400.3168@hadrien \
--to=julia.lawall@lip6.fr \
--cc=cocci@systeme.lip6.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.