Coccinelle archive mirror
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: cocci@inria.fr
Subject: [cocci] Transforming source code according to the usage of a predicate
Date: Sun, 25 Dec 2022 17:42:26 +0100	[thread overview]
Message-ID: <7da2d07d-c1fb-1a58-8b57-3d1248f70c87@web.de> (raw)

Hello,

I noticed a suggestion in another issue tracker.

2022-11-25
Detect if/else branches that only differ by condition variable
https://trac.cppcheck.net/ticket/11402


I tried to construct a script variant for the semantic patch language
(software combination “Coccinelle 1.1.1”) accordingly.


@replacement disable neg_if, drop_else@
bool active;
expression call;
@@
 <+...
(
-if (active) {
    call(active, ...);
-} else {
-   call(!active, ...);
-}
|
-if (active) {
    call(..., active);
-} else {
-   call(..., !active);
-}
)
 ...+>



I hoped that an isomorphism can take care of special compound statements.
https://gitlab.inria.fr/coccinelle/coccinelle/-/blob/87350d742df39d847b15af39865329c2fe23460d/standard.iso#L523

Unfortunately, I stumbled on information like the following.


Markus_Elfring@Sonne:…/Projekte/Coccinelle/Probe> spatch --parse-cocci cppcheck-11402-suggestion2-20221225.cocci
…
warning: iso braces4 does not match the code below on line 7
…


Will the chances grow to simplify and improve the shown SmPL code any further?

Regards,
Markus


             reply	other threads:[~2022-12-25 16:42 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-25 16:42 Markus Elfring [this message]
2022-12-26  6:41 ` [cocci] Transforming source code according to the usage of a predicate Julia Lawall
2022-12-26 11:12   ` Markus Elfring
2022-12-26 11:19     ` Julia Lawall
2022-12-26 11:36       ` Markus Elfring
2022-12-26 14:10       ` Markus Elfring
2022-12-27  9:36       ` [cocci] Another extension for the software documentation Markus Elfring
2022-12-27  9:47         ` Julia Lawall
2022-12-27 11:40           ` Markus Elfring
2022-12-27 12:53             ` Julia Lawall
2022-12-27 13:00               ` Markus Elfring
2023-01-07 11:46       ` [cocci] Working with filled data structures Markus Elfring
2023-01-07 12:55         ` Julia Lawall
2023-01-07 13:11           ` Markus Elfring
2023-01-07 13:25             ` Julia Lawall
2023-01-07 13:34               ` Markus Elfring
2023-01-07 13:45                 ` Julia Lawall
2023-01-07 13:56                   ` 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=7da2d07d-c1fb-1a58-8b57-3d1248f70c87@web.de \
    --to=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 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 read-only IMAP folder(s) and NNTP newsgroup(s).