On Wed, 21 Jan 2015, Eliseo Martínez wrote:
>
> > Then, would there be any way to match functions having the
> >> literal “FUNC_ATTR_NONNULL_RET” in their declaration/definition?
> >
> > Would you like to try it out how many source code places can be found
> > with your macro name?
>
> This approach
> ```
> @nonnullfuncs@ identifier func; @@
>
> * func
> (...)
> ... FUNC_ATTR_NONNULL_RET ...
> {...}
> ```
> matches nothing.
I'm surprised that it parses. Matching of attributes is not supported.
Parsing them in C code is too (or at least very) difficult, and they are
all shifted into comments.
> >> @@ identifier func =~ "^(transstr|list_alloc|listitem_alloc| [...]
> >> |concat_str)$"; [...] @@
> >>
> >> var = func(...);
> >> ... when != var = E
> >> (
> >> * if (var == NULL) S;
> >> |
> >> * if (var != NULL) S;
> >> )
> >
> > Does this kind of SmPL disjunction make sense?
You don't want the semicolon after S. That means a statement followed by
a semicolon, which could match something like x = 3;;, that is the
statement x = 3; followed by another semicolon.
Only use regular expressions if you absolutely have to. They are not
interpreted when preselecting files, so they drasticaly hurt performance.
> I don’t see why not. AFAIK, Disjunctions can contain a full term
> (identifier/expression/statement). Regarding meaning, well, I’m looking
> for places where var is checked for nullness/non-nullnes. That’s the
> most obvious way I’ve found to express that…
>
> >> As you see, I have to replicate the list.
> >>
> > I would also appreciate if such repetition could be avoided for
> > SmPL constraints.
>
> I’ve tried with rule inheritance, but don’t know what to put in a first
> rule that just “selects” the functions. This is:
>
> ```
> @r@ identifier func =~ “…list of names… “ @@
>
> … What here???
>
> @@ identifier r.func @@
>
> (
> * if (func(…) == NULL) S;
> |
> * if (func(…) != NULL) S;
> )
> ```
I'm not following the goal here.
julia
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci