From: Julia Lawall <julia.lawall@lip6.fr>
To: Markus Elfring <Markus.Elfring@web.de>
Cc: Coccinelle <cocci@systeme.lip6.fr>
Subject: Re: [Cocci] Working with backreferences in SmPL scripts?
Date: Wed, 17 Apr 2019 09:57:46 +0200 (CEST) [thread overview]
Message-ID: <alpine.DEB.2.21.1904170956300.2612@hadrien> (raw)
In-Reply-To: <39151ab1-0310-95cb-bbcc-c5edb4a179d9@web.de>
[-- Attachment #1: Type: text/plain, Size: 1954 bytes --]
On Wed, 17 Apr 2019, Markus Elfring wrote:
> Hello,
>
> I have tried another small SmPL script out.
>
>
> @replacement@
> expression ex;
> identifier var;
> @@
> var
> - = var +
> + +=
> ex
>
>
> elfring@Sonne:~/Projekte/Coccinelle/Probe> spatch simplify_addition1.cocci Test_increment1.c
> …
> @@ -1,6 +1,6 @@
> int main(void)
> {
> int counter = 3;
> -counter = counter + 5;
> +counter += 5;
> return counter;
> }
>
>
> I have repeated this transformation approach with the following source code.
>
>
> int main(void)
> {
> int x = 2, y = 3;
> x = y + 5;
> return x;
> }
A metavariable is always bound to the same value within a given
control-flow path. I have no idea what you are trying to get at with
this example.
julia
>
>
> This test example did not present a generated change suggestion.
> I find that such a result can be interpreted in two ways then.
>
> 1. The Coccinelle software ensured that the specified metavariable “var”
> referred to the same source code at all shown places with the consequence
> that the variable “y” could not match in this test case.
>
> 2. A possible data output was not displayed despite of the detail
> that the variable “y” is also an identifier according to the syntax of
> the C programming language.
> Would there be a need to express a relationship to a previous match
> by a kind of notation for backreferences?
>
>
> The situation can become challenging for the safe handling of advanced
> statements in more meaningful source files.
>
> * How do you think about to help with the reconsideration
> (and occasional deletion) of duplicate code by the means of
> the semantic patch language?
>
> * Would you like to clarify the desired software behaviour for such use cases?
>
> Regards,
> Markus
> _______________________________________________
> Cocci mailing list
> Cocci@systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
>
[-- Attachment #2: Type: text/plain, Size: 136 bytes --]
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci
next prev parent reply other threads:[~2019-04-17 7:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-17 7:45 [Cocci] Working with backreferences in SmPL scripts? Markus Elfring
2019-04-17 7:57 ` Julia Lawall [this message]
2019-04-17 8:23 ` 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.21.1904170956300.2612@hadrien \
--to=julia.lawall@lip6.fr \
--cc=Markus.Elfring@web.de \
--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 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).