Re: [cocci] Searching function implementations with more than a single return?

Julia Lawall
2025-07-01T13:59:58Z

On Tue, 1 Jul 2025, Markus Elfring wrote:

> >>> Another SmPL script example:
> >> for further development considerations?
> >>
> >> @display@
> >> identifier i;
> >> statement s;
> >> statement list sl;
> >> type t;
> >> @@
> >> (return ...;
> >> |t i;
> >> (
> >> <+...
> >> *s
> >> ...+>
> >> |
> >> *sl
> >> )
> >> )
> >
> > This one makes no sense, because return and t i; can't match the same
> > thing. So the disjunction has no impact.
> Would you like to suggest the exclusion of a single return statement
> by a more appropriate source code search approach?

Requiring the presence of a declaration already excludes the case of a
single return. If you want to exclude a single return after a
declaration, then the return should be put in the disjunctions with the
*s. The *sl will again never match anything, because it's not coming
immediately after a {}. It comes immediately after a declaration.

julia