All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julia Lawall <julia.lawall@inria.fr>
To: Markus Elfring <Markus.Elfring@web.de>
Cc: cocci@inria.fr
Subject: Re: [cocci] Searching for repeated source code with SmPL?
Date: Sun, 12 May 2024 09:34:29 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.22.394.2405120932360.6747@hadrien> (raw)
In-Reply-To: <c26d41ba-7d55-402b-92a0-5c3d4112893a@web.de>

[-- Attachment #1: Type: text/plain, Size: 1689 bytes --]



On Sun, 12 May 2024, Markus Elfring wrote:

> > Your semantic patch needs to be:
> >
> > @display@
> > @@
> >  my_action(...);
> >  <+... when any
> > *my_action(...);
> >  ...+>
> >
> > Without that, a call to my_action is forbidden in the region matched by
> > the <+... ...+>.  Because any kind of dot thing matches the shortest path
> > between what comes before and what comes after (here the end of the function).
>
> Can the Coccinelle software inform better about the case that the shortest
> path constraint was “accidentally overlooked” in a SmPL script?
>
>
> There are further development challenges to consider.
> See also a corresponding transformation approach by the means of
> another tiny script for the semantic patch language:
>
> @adjustment@
> @@
>  my_action(
> -          ...
> +          0
>           );
>  <+... when any
> -my_action(...);
>  ...+>
>
>
> Test result:
> Markus_Elfring@Sonne:…/Projekte/Coccinelle/Probe> spatch use_one_test_call.cocci repeated_three_calls.c
> …
> previous modification:
>
>   <<< 0
> CONTEXT
>
> According to environment 0:
>
>
> current modification:
> MINUS
>
> According to environment 0:
>
>
> adjustment: already tagged token:
> C code context
> File "repeated_three_calls.c", line 4, column 12, charpos = 48
>   around = ')',
>   whole content =  my_action(2);
>
>
> Can the data processing be improved anyhow?

The current semantic pach allows the first my_action to match anywhere,
including the second my_action, third, etc.  So if you have changes in
both, then there will be contradictory changes to the code.

Probably you should start with ... when != my_action(...) to be sure to
get the first one.

julia

  reply	other threads:[~2024-05-12  7:34 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-06 10:08 [cocci] Searching for repeated source code with SmPL? Markus Elfring
2024-05-06 10:09 ` Julia Lawall
2024-05-06 11:03   ` Markus Elfring
2024-05-06 12:10   ` Markus Elfring
2024-05-06 12:16     ` Julia Lawall
2024-05-06 12:40       ` Markus Elfring
2024-05-11 15:36   ` Markus Elfring
2024-05-11 16:04     ` Julia Lawall
2024-05-11 16:35       ` Markus Elfring
2024-05-11 16:37         ` Julia Lawall
2024-05-11 17:02           ` Markus Elfring
2024-05-11 17:12             ` Julia Lawall
2024-05-11 17:21               ` Markus Elfring
2024-05-11 17:33                 ` Julia Lawall
2024-05-12  6:48       ` Markus Elfring
2024-05-12  7:34         ` Julia Lawall [this message]
2024-05-12  8:01           ` Markus Elfring
2024-05-12  8:10             ` Julia Lawall
2024-05-12  8:33               ` Markus Elfring
2024-05-12  9:17                 ` Julia Lawall
2024-05-12  9:30                   ` Markus Elfring
2024-05-13  9:34                   ` Markus Elfring
2024-05-12 11:24           ` Markus Elfring
2024-05-12 12:53             ` Julia Lawall
2024-05-12 13:07               ` Markus Elfring
2024-05-12 13:13                 ` Julia Lawall
2024-05-12 13:22                   ` Markus Elfring
2024-05-12 14:51                   ` Markus Elfring
2024-05-12 14:57                     ` Julia Lawall
2024-05-11  7:15 ` Markus Elfring
2024-05-22  8:20 ` Markus Elfring
2024-05-22  8:24   ` Julia Lawall
2024-05-22  8:44     ` Markus Elfring
2024-05-22 13:12     ` Markus Elfring
2024-05-22 15:34       ` Julia Lawall
2024-05-22 16:06         ` 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=alpine.DEB.2.22.394.2405120932360.6747@hadrien \
    --to=julia.lawall@inria.fr \
    --cc=Markus.Elfring@web.de \
    --cc=cocci@inria.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.