All of lore.kernel.org
 help / color / mirror / Atom feed
From: julia.lawall@lip6.fr (Julia Lawall)
To: cocci@systeme.lip6.fr
Subject: [Cocci] Matching functions with attributes
Date: Thu, 22 Jan 2015 16:44:59 +0200 (SAST)	[thread overview]
Message-ID: <alpine.DEB.2.10.1501221641040.4079@hadrien> (raw)
In-Reply-To: <508792FB-D90F-4E07-9F3E-96553412648E@gmail.com>



On Thu, 22 Jan 2015, Eliseo Mart?nez wrote:

> > I get nothing
>
> Given that patch (which does not include ?home_replace? in the regex), that would be the expected result.
> Note that I didn?t include the full list of functions in my last patch (not to make it more confusing than necessary), but the actual patch I?m using contains all functions, including ?home_replace?.
>
> In any case, I?ve just realized the problem could be not in spatch, but in how I?m parsing its output through vim?s errorformat.
> So, please, forget about this by now, and sorry for the noise.
> If I do isolate a real failure in spatch, I will get back to you with a complete set of patch/source to reproduce it.

If the regular expression is a positive thing, then you would probably be
better off with

var = \(fun1\|fun2\|fun3\|fun4\)(...)
...
etc.

The Coccinelle will only parse the files that contain either fun1, fun2,
fun3, fun4, etc.

Actually, you don't even have to repeat the long list of functions for the
two rules.  You can say:

@ok@
position p;
@d@

\(fun1\|fun2\|fun3\|fun4\)(...)@p

@@
...
identifier fn;
position ok.p;
@@

var = fn(...)@p
... when != var = E
*if (var == NULL) S

etc.

It will detect that the semantic patch can only do something useful on a
file that contains either fun1, fun2, etc.

julia

>
> Thanks.
>
>
> > On 22 Jan 2015, at 12:52, Julia Lawall <julia.lawall@lip6.fr> wrote:
> >
> > With the following source code:
> >
> > int main() {
> >     p = home_replace(NULL, files[i]);
> >      if (p != NULL) {
> >        free(files[i]);
> >        files[i] = p;
> >      }
> > }
> >
> > and the following semanticpatch:
> >
> > @@ identifier func =~ "^(vim_strsave|list_alloc)$"; identifier var;
> > statement S; expression E; @@
> >
> >  var = func(...);
> >  ... when != var = E
> > * if (var != NULL)
> >    S
> >
> > I get nothing.  If I remove the regular expression, then I get results
> > with the above semantic patch and with the following semantic partch:
> >
> > @@ identifier func =~ "^(vim_strsave|list_alloc)$"; identifier var;
> > statement S; expression E; @@
> >
> >  var = func(...);
> >  ... when != var = E
> > * if (var != NULL)    S
> >
> > Probably the issue inmy case is the kind of regular expression being used.
> > Are you using pcre?
> >
> > julia
>
>

  reply	other threads:[~2015-01-22 14:44 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-21 14:05 [Cocci] Matching functions with attributes Eliseo Martínez
2015-01-21 16:15 ` SF Markus Elfring
2015-01-21 17:28   ` Eliseo Martínez
2015-01-21 18:03     ` SF Markus Elfring
2015-01-21 21:36       ` Eliseo Martínez
2015-01-21 21:46     ` Julia Lawall
2015-01-21 22:47       ` Eliseo Martínez
2015-01-22  5:58         ` Julia Lawall
2015-01-22  8:45         ` SF Markus Elfring
2015-01-22  8:59         ` SF Markus Elfring
2015-01-22  9:23           ` Eliseo Martínez
2015-01-22  9:36             ` Eliseo Martínez
2015-01-22 10:11               ` SF Markus Elfring
2015-01-22 11:52             ` Julia Lawall
2015-01-22 12:56               ` Eliseo Martínez
2015-01-22 14:44                 ` Julia Lawall [this message]
2015-01-22 15:28                 ` SF Markus Elfring
2015-01-22  8:29       ` [Cocci] Run time differences between SmPL disjunctions and regular expressions (in constraints) SF Markus Elfring
2015-01-22  8:37         ` Julia Lawall
2015-01-22  9:50           ` SF Markus Elfring
2015-01-27 19:01 ` [Cocci] Matching functions with attributes 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.10.1501221641040.4079@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.