Re: [cocci] Searching function implementations with variable declarations and statements?

Julia Lawall
2025-07-01T12:29:39Z

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

On Tue, 1 Jul 2025, Markus Elfring wrote:

> >> Should any diff output be produced accordingly?
> > Probably not. Statement list metavariables only match the list of
> > statements that occur at top level within {}.
>
> Do you occasionally prefer a source code search approach like the following?
>
> Another SmPL script example:
> @display2@
> statement s;
> identifier i;
> type t;
> @@
> <+...
> *t i;
> ...+>
> s

This seems more promising.

julia

>
>
> Markus_Elfring@Sonne:…/Projekte/Linux/next-analyses> time /usr/bin/spatch --no-loops …/Projekte/Coccinelle/janitor/show_variable_declarations_before_statements2.cocci include/…
> @@ -666,7 +666,6 @@ static inline int usb_endpoint_maxp(cons
> …
> @@ -721,7 +720,6 @@ struct usb_ss_ep_comp_descriptor {
> …
> real 0m0,250s
> user 0m0,202s
> sys 0m0,048s
>
>
> Regards,
> Markus
>