All of lore.kernel.org
 help / color / mirror / Atom feed
* [cocci] Transforming source code according to the usage of a predicate
@ 2022-12-25 16:42 Markus Elfring
  2022-12-26  6:41 ` Julia Lawall
  0 siblings, 1 reply; 18+ messages in thread
From: Markus Elfring @ 2022-12-25 16:42 UTC (permalink / raw)
  To: cocci

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


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2023-01-07 13:56 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-25 16:42 [cocci] Transforming source code according to the usage of a predicate Markus Elfring
2022-12-26  6:41 ` 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

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.