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

Julia Lawall
2025-07-01T15:18:02Z

On Tue, 1 Jul 2025, Markus Elfring wrote:

> >> 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.
>
> Variable declarations (and definition) can also be specified after
> a return statement, can't they?

In terms of execution, nothing happens after a return statesment.

And anyway, after the return is not the issue here. You have a pattern
that at each node in the CFG searches for either a return or a variable
declaration. In the case of a return it does nothing. Since no node can
match both the disjunction doesn't have any useful effect.

>
>
> > 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.
>
> Is the handling of curly brackets (for compound statements) still unclear
> so far?

I see nothing unclear. You can write { sl }. You can't write S1 sl S2.
There exists no representation of a list of statements that sl can bind
to.

julia