From: julia.lawall@lip6.fr (Julia Lawall)
To: cocci@systeme.lip6.fr
Subject: [Cocci] Problem matching macro invoked on file scope
Date: Tue, 8 Jan 2013 10:28:51 +0100 (CET) [thread overview]
Message-ID: <alpine.DEB.2.02.1301081028060.1942@hadrien> (raw)
In-Reply-To: <CAACXqO8YWmf6hNCZGUU4-WNptxnR2T=Ph55b-w4xWAT_uCE-WQ@mail.gmail.com>
On Tue, 8 Jan 2013, H?kon L?vdal wrote:
> On 7 January 2013 16:43, Lars-Peter Clausen <lars@metafoo.de> wrote:
> > Hi,
> >
> > try to add
> >
> > declarer name ASYNC_DOMAIN;
> >
> > to your cocci rule.
>
> Exellent, yes this was exactly what I was missing. With that the script prints
>
> ASYNC_DOMAIN is called with _name equal to async_running
> ASYNC_DOMAIN is called with _name equal to scsi_sd_probe_domain
>
> for the linux files. So the problem I started with is solved.
> The following is not important to get an answer to, but I was a little
> bit surprised and would like to understand the issue.
>
> I ran the script on the dummy_async_domain_test.c file as well and it
> now only matches mytest1 and mytest2, which is expected behaviour as far
> as I can tell. Out of curiosity I thought that if I wanted to match all
> four cases then I could just add an additional rule without declarer, e.g.
>
>
> // with declarer
> @rule1@
> declarer name ASYNC_DOMAIN;
> identifier id;
> @@
> ASYNC_DOMAIN(id);
>
> @script:python@
> id << rule1.id;
> @@
> print "1: ASYNC_DOMAIN is called with _name equal to %s" % (id)
>
> // without declarer
> @rule2@
> identifier id;
> @@
> ASYNC_DOMAIN(id);
>
> @script:python@
> id << rule2.id;
> @@
> print "2: ASYNC_DOMAIN is called with _name equal to %s" % (id)
>
>
> but running with this gives
>
> 1: ASYNC_DOMAIN is called with _name equal to mytest1
> 1: ASYNC_DOMAIN is called with _name equal to mytest2
> 2: ASYNC_DOMAIN is called with _name equal to mytest1
> 2: ASYNC_DOMAIN is called with _name equal to mytest2
>
> so it seems that the declarer property from rule1 is "leaking" into
> rule2 as well. Is this intended behaviour? If I reverse the order and
> put rule2 and the corresponding python script at the top then it prints
> like I expected in the first place.
>
> 2: ASYNC_DOMAIN is called with _name equal to mytest3
> 2: ASYNC_DOMAIN is called with _name equal to mytest4
> 1: ASYNC_DOMAIN is called with _name equal to mytest1
> 1: ASYNC_DOMAIN is called with _name equal to mytest2
Yes, for typedefs, declarer names, and iterator names, it assumes that
once you have declared them, you would always like to use them in that
way.
julia
next prev parent reply other threads:[~2013-01-08 9:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-07 15:34 [Cocci] Problem matching macro invoked on file scope Håkon Løvdal
2013-01-07 15:43 ` Lars-Peter Clausen
2013-01-08 9:22 ` Håkon Løvdal
2013-01-08 9:28 ` Julia Lawall [this message]
2013-01-08 9:33 ` Håkon Løvdal
2013-01-07 15:45 ` Julia Lawall
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.02.1301081028060.1942@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox