Coccinelle archive mirror
 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] Reconsidering application of selected SmPL isomorphisms
Date: Mon, 25 Nov 2024 10:42:58 -0500 (EST)	[thread overview]
Message-ID: <9e8d6626-f8a2-19a7-33d3-b0cc48d2fa68@inria.fr> (raw)
In-Reply-To: <434d257c-f0a5-483d-9fcb-3303301ad867@web.de>

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



On Mon, 25 Nov 2024, Markus Elfring wrote:

> Hello,
>
> I would like to clarify software development consequences also for
> a simple script variant for the semantic patch language (like the following).

The generated code indeed does not look ideal.  But it won't cause any
wrong matches.  The isomorphisms are applied on the ASTs, not on the soure
code.  So there will be a tree with a ! at the root and a || as the
argument that will not match any possible source code.

Maybe it would be better to add isomorphisms for the de Morgan laws rather
than adding some hacks into the generic isomorphism transformation to take
this issue into account.

julia

>
>
> @show_questionable_checks@
> expression e1, e2;
> statement s1, s2;
> @@
>  if
>  (
> *!(e1 || e2)
>  )
>     s1
>  else
>     s2
>
>
> Questionable test result:
> Markus_Elfring@Sonne:/home/altes_Heim2/elfring/Projekte/Coccinelle/janitor> spatch --parse-cocci show_questionable_OR_checks2.cocci
> …
> (
>
> (
>
> (
> if (*!*(*e1 *|| *e2*))
> |
> if (*!*e1 *|| *e2)
> )s1 else s2
> |
> …
>
>
> I would interpret such data display in the way that the isomorphism “paren”
> was applied here.
> https://gitlab.inria.fr/coccinelle/coccinelle/-/blob/04f71e76b0857ca12ec7207b26368df78d2b57d4/standard.iso#L389
>
> I find the shown SmPL code transformation inappropriate at this place.
> Would we like to apply De Morgan's laws instead?
> https://en.wikipedia.org/wiki/De_Morgan%27s_laws
>
> Would we like to reconsider the application of the isomorphism for the switching
> of if/else branches accordingly?
>
> Regards,
> Markus
>

  parent reply	other threads:[~2024-11-25 15:43 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-25 13:16 [cocci] Reconsidering application of selected SmPL isomorphisms Markus Elfring
2024-11-25 15:37 ` Julia Lawall
2024-11-25 15:42 ` Julia Lawall [this message]
2024-11-25 16:13   ` Markus Elfring
2024-11-25 16:23     ` Julia Lawall
2024-11-25 16:34       ` Markus Elfring
2024-11-25 16:46         ` Julia Lawall
2024-11-25 16:57           ` [cocci] Advanced handling of logical operator chains (with SmPL)? Markus Elfring
2024-11-25 17:03             ` Julia Lawall
2024-11-25 17:08               ` Markus Elfring
2024-11-25 17:04       ` [cocci] Data processing challenges for pointer expressions Markus Elfring
2024-11-25 17:16         ` Julia Lawall
2024-11-25 17:58           ` Markus Elfring
2024-11-26  9:21           ` [cocci] Data processing challenges for source code analyses 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=9e8d6626-f8a2-19a7-33d3-b0cc48d2fa68@inria.fr \
    --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 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).