From: der.herr@hofr.at (Nicholas Mc Guire)
To: cocci@systeme.lip6.fr
Subject: [Cocci] Question about the use of "...when !=" in SmPL
Date: Sat, 9 May 2015 18:49:47 +0200 [thread overview]
Message-ID: <20150509164947.GA12173@opentech.at> (raw)
In-Reply-To: <20150509140941.GA13643@opentech.at>
On Sat, 09 May 2015, Nicholas Mc Guire wrote:
> On Thu, 07 May 2015, ZhouYuan wrote:
>
> your second question regardin if/else was not yet addressed - so here are
> some notes on trying to solve this - again this might not be the right
> approach - only got it to work by removing the if structure isomorphisms !
>
> <snip>
> >
> > Also, another example can be witnessed here. I wrote another patch to
> > check whether there is an "else" after "if" statement:
> >
> > @rule534@
> > function F;
> > position p;
> > statement S1, S2;
> > @@
> > F at p (...){
> > if (...) S1
> > ...when != else S2
> > }
> >
> > But i also got the same "minus: parse error" at the line of when.
> > I would be so appreciated if someone could give me some suggestions about
> > what is wrong in my Patch and how to use when correctly.
> > Thank you so much!
>
forget my first attempt - obviously confused my self sufficiently to find
a very complicated solution to a simple problem - no need to change the
iso file either....
<snip>
virtual report
virtual org
@ifonly@
function f;
statement S1;
position p;
@@
f (...){
<...
*if@p (...) S1
...>
}
@script: python depends on ifonly@
p<<ifonly.p;
@@
print "%s %s if without else" % (p[0].file, p[0].line)
<snip>
note that if one really would need to disable some specific isomorphism
then one can do that with "disable" e.g. from the "if structure isomorphisms"
section in standard.iso you could selectively disable neg_if and ne_if like
so:
@ifonly disable ne_if,neg_if@
(see http://www.emn.fr/z-info/coccinelle/docs/main_grammar002.html#disable-iso)
but for this case this is not needed anyway.
So the only problem with your soluion was that you were trying to explicitly
describe the absence while all you would need is to describe what you want
to see.
Just ran this on the kernel and the first few pages of output looked like
its working.
thx!
hofrat
next prev parent reply other threads:[~2015-05-09 16:49 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-07 2:32 [Cocci] Question about the use of "...when !=" in SmPL ZhouYuan
2015-05-09 7:47 ` Nicholas Mc Guire
2015-05-09 8:10 ` [Cocci] Source code analysis around "switch" SF Markus Elfring
2015-05-09 8:28 ` Nicholas Mc Guire
2015-05-09 8:40 ` SF Markus Elfring
2015-05-09 8:36 ` [Cocci] Question about the use of "...when !=" in SmPL Julia Lawall
2015-05-09 10:08 ` Nicholas Mc Guire
2015-05-09 14:09 ` Nicholas Mc Guire
2015-05-09 16:47 ` Julia Lawall
2015-05-10 7:29 ` [Cocci] Data provided by position variables SF Markus Elfring
2015-05-10 8:40 ` Julia Lawall
2015-05-10 8:47 ` SF Markus Elfring
2015-05-09 16:49 ` Nicholas Mc Guire [this message]
2015-05-10 7:49 ` [Cocci] Improving small SmPL examples SF Markus Elfring
2015-05-10 12:58 ` [Cocci] Question about the use of "...when !=" in SmPL Julia Lawall
2015-05-10 16:28 ` [Cocci] Fine-tuning for switch statements SF Markus Elfring
2015-05-10 16:31 ` Julia Lawall
2015-05-10 16:34 ` 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=20150509164947.GA12173@opentech.at \
--to=der.herr@hofr.at \
--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.