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

Markus Elfring
2025-07-01T12:27:02Z

>> 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

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