Re: [Cocci] [PATCH] coccinelle: misc: add swap script

2021-02-18 Thread Julia Lawall
On Thu, 18 Feb 2021, Markus Elfring wrote: > > A disjunction basically says "at this node in the cfg, can I match the > > first patter, or can I match the second pattern, etc." Unfortunately in > > this case the two branches start matching at different nodes, so the short > > circuit aspect

Re: [Cocci] [PATCH] coccinelle: misc: add swap script

2021-02-18 Thread Denis Efremov
On 2/18/21 2:29 PM, Julia Lawall wrote: > > > On Thu, 18 Feb 2021, Denis Efremov wrote: > >> >> >> On 2/18/21 1:17 PM, Julia Lawall wrote: >>> >>> >>> On Thu, 18 Feb 2021, Denis Efremov wrote: >>> On 2/18/21 12:31 AM, Julia Lawall wrote: >> +@depends on patch@ >>

Re: [Cocci] [PATCH] coccinelle: misc: add swap script

2021-02-18 Thread Julia Lawall
On Thu, 18 Feb 2021, Denis Efremov wrote: > > > On 2/18/21 1:17 PM, Julia Lawall wrote: > > > > > > On Thu, 18 Feb 2021, Denis Efremov wrote: > > > >> > >> > >> On 2/18/21 12:31 AM, Julia Lawall wrote: > +@depends on patch@ > +identifier tmp; > +expression a, b; > +type T;

Re: [Cocci] [PATCH] coccinelle: misc: add swap script

2021-02-16 Thread Markus Elfring
> +- tmp = a; > +- a = b; > +- b = tmp; > ++ swap(a, b); How do you think about to use the following SmPL code variant? * Omission of a few leading space characters * Keeping a semicolon unmodified in a line +-tmp = a; +-a = b; +-b = tmp ++swap(a, b) +; Regards, Markus

[Cocci] [PATCH] coccinelle: misc: add swap script

2021-02-16 Thread Denis Efremov
Check for opencoded swap() implementation. Signed-off-by: Denis Efremov --- scripts/coccinelle/misc/swap.cocci | 77 ++ 1 file changed, 77 insertions(+) create mode 100644 scripts/coccinelle/misc/swap.cocci diff --git a/scripts/coccinelle/misc/swap.cocci