Re: [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: [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: [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: [PATCH] coccinelle: misc: add swap script

2021-02-18 Thread Denis Efremov
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; +@@ + +( +- T tmp; +| +- T tmp = 0;

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

2021-02-18 Thread Julia Lawall
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; > >> +@@ > >> + > >> +( > >> +- T tmp; > >> +| > >> +- T tmp = 0; > >> +| > >> +- T *tmp = NULL; > >> +) > >> +... when

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

2021-02-17 Thread Denis Efremov
On 2/18/21 12:31 AM, Julia Lawall wrote: >> +@depends on patch@ >> +identifier tmp; >> +expression a, b; >> +type T; >> +@@ >> + >> +( >> +- T tmp; >> +| >> +- T tmp = 0; >> +| >> +- T *tmp = NULL; >> +) >> +... when != tmp >> +- tmp = a; >> +- a = b; >> +- b = tmp; >> ++ swap(a, b); >> +...

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

2021-02-17 Thread Julia Lawall
> +@depends on patch@ > +identifier tmp; > +expression a, b; > +type T; > +@@ > + > +( > +- T tmp; > +| > +- T tmp = 0; > +| > +- T *tmp = NULL; > +) > +... when != tmp > +- tmp = a; > +- a = b; > +- b = tmp; > ++ swap(a, b); > +... when != tmp In this rule and the next one, if you remove the

[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