From: der.herr@hofr.at (Nicholas Mc Guire)
To: cocci@systeme.lip6.fr
Subject: [Cocci] Source code analysis around "switch"
Date: Sat, 9 May 2015 10:28:04 +0200 [thread overview]
Message-ID: <20150509082804.GA13329@opentech.at> (raw)
In-Reply-To: <554DC0FA.4010904@users.sourceforge.net>
On Sat, 09 May 2015, SF Markus Elfring wrote:
> > @hascase@
> > position p;
> > @@
> > switch at p (...)
> > {
> > case...:...
> > }
> >
> > @hasdefault@
> > @@
> > switch (...)
> > {
> > default:...
> > }
> >
> > @script: python depends on hascase && !hasdefault@
> > p<<hascase.p;
> > @@
> > print "%s %s" % (p[0].file, p[0].line)
> >
> > there likely is a simpler solution than this though.
>
> I find such a SmPL approach incomplete.
What is the incompleteness - or what case do you think is unhandled ?
> Is the shown condition expression fragile and questionable?
>
> Do you need to work more with position variables there
> so that only really appropriate source code places
> will be combined and then checked?
>
why ? hascase has a position variable in it and only if
that rule applied is the python script executed - and if there
was a default then hasdefault matched and so the python script
will not be executed when hasdefault matched => only switch
statements with no default are reported. Atleast it sems to work
for me - but as noted there well may be a better solution and
maybe its even incomplete - but I do not see that its a missing
positional variable here.
thx!
hofrat
next prev parent reply other threads:[~2015-05-09 8:28 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 [this message]
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 ` [Cocci] Question about the use of "...when !=" in SmPL Nicholas Mc Guire
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=20150509082804.GA13329@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.