From: Julia Lawall <julia.lawall@lip6.fr>
To: Timur Tabi <timur@kernel.org>
Cc: cocci <cocci@systeme.lip6.fr>
Subject: Re: [Cocci] How to concatenate identifier with text?
Date: Wed, 12 Jun 2019 07:25:52 +0200 (CEST) [thread overview]
Message-ID: <alpine.DEB.2.21.1906120724230.2535@hadrien> (raw)
In-Reply-To: <CAOZdJXVsdJHZyWSXzOsJTTOj8R=UZcD4yZVxXBB1TELJLT1wSA@mail.gmail.com>
On Tue, 11 Jun 2019, Timur Tabi wrote:
> On Fri, May 24, 2019 at 2:38 PM Julia Lawall <julia.lawall@lip6.fr> wrote:
> > On Fri, 24 May 2019, Timur Tabi wrote:
> > > I figured it out:
> > >
> > > @@
> > > identifier func;
> > > fresh identifier label = func ## "_exit";
> >
> > Yes, that works too. Simpler than my suggestion.
>
> I managed to break it somehow. I suspect I ran into some other quirk
> of coccinelle. I'm trying to convert that looks like this:
>
> x = MACRO1(stuff);
> if (x == NULL)
> {
> BREAKPOINT();
> status = ERROR;
> goto myfunc_exit;
> }
>
> into:
> x = MACRO1(stuff);
> CHECK_OR_BP_AND_GOTO(x == NULL, status, ERROR, _exit);
>
> I thought this would work:
>
> @@
> type T;
> expression y, z;
> identifier x, s;
> identifier func;
> fresh identifier label = func ## "_exit";
> @@
> func(...) {
> <+...
> x =
> (T)
> \(MACRO1\|MACRO2\)
> (...);
> -if (y)
> -{
> - BREAKPOINT();
> - s = z;
> - goto label;
> -}
> +CHECK_OR_BP_AND_GOTO(y, s, z, _exit);
> ...
> label:
> ...+>
> }
>
> but I get this error:
>
> 18: unexpected use of a fresh identifier label
>
> What am I missing?
Fresh identifiers are only for + code.
You need to construct the identifier you want to match using python code,
as illustrated in demos/pythontococci.cocci
julia
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci
next prev parent reply other threads:[~2019-06-12 5:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-24 19:13 [Cocci] How to concatenate identifier with text? Timur Tabi
2019-05-24 19:36 ` Timur Tabi
2019-05-24 19:38 ` Julia Lawall
2019-06-11 21:51 ` Timur Tabi
2019-06-11 21:58 ` Timur Tabi
2019-06-12 7:12 ` [Cocci] Wider usage of “fresh identifiers”? Markus Elfring
2019-06-12 5:25 ` Julia Lawall [this message]
2019-05-24 19:38 ` [Cocci] How to concatenate identifier with text? 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.21.1906120724230.2535@hadrien \
--to=julia.lawall@lip6.fr \
--cc=cocci@systeme.lip6.fr \
--cc=timur@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).