From: Markus Elfring <Markus.Elfring@web.de>
To: Coccinelle <cocci@systeme.lip6.fr>
Subject: [Cocci] Working with backreferences in SmPL scripts?
Date: Wed, 17 Apr 2019 09:45:46 +0200 [thread overview]
Message-ID: <39151ab1-0310-95cb-bbcc-c5edb4a179d9@web.de> (raw)
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;
}
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
next reply other threads:[~2019-04-17 7:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-17 7:45 Markus Elfring [this message]
2019-04-17 7:57 ` [Cocci] Working with backreferences in SmPL scripts? Julia Lawall
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=39151ab1-0310-95cb-bbcc-c5edb4a179d9@web.de \
--to=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).