Subject: Re: [PATCH v2 0/4] Makefile/coccicheck: fix bugs and speed it up

From: René Scharfe. <[email-masked]>
Date: Sat, 6 Mar 2021 20:08:39 +0100

Am 06.03.21 um 18:52 schrieb Ævar Arnfjörð Bjarmason:
>
> On Sat, Mar 06 2021, René Scharfe. wrote:
>
>> Am 06.03.21 um 18:27 schrieb Ævar Arnfjörð Bjarmason:
>>> Do these sorts of rules really benefit that much from the type
>>> v.s. expression? If yes we'll obviously need to support it, but if (and
>>> I haven't looked closely) we can equally rewrite them with "expression"
>>> (or it would be good enough) we could be quite a bit faster by
>>> default...
>>
>> Type information is essential for many (most?) semantic patches.
>> Untyped replacements could be done more easily using sed or similar.
>
> We have 65 individual hunks in *.cocci by my count $((/ (cat *.cocci |
> grep -c ^@@) 2)), but only 9 of those use the "type T" construct, which
> AFAICT is the only thing affected.

I don't understand why using type variables would be the only feature
that needs headers.  Accessing struct members like in commit.cocci surely
needs their definition, no?
> There's still plenty of reason to use spatch without headers being
> included, it's still doing a full parse and knows that something's a
> function, and otherwise cares about C syntax etc.
>
> Anyway, I'm not saying you don't need it, just that AFAICT it's a small
> minority of the rules that require the includes.

https://coccinelle.gitlabpages.inria.fr/website/docs/options.pdf says
"If the semantic patch contains type specifications on expression
metavariables, then the default is --local-includes. Otherwise the
default is --no-includes."   So spatch by default already avoids loading
includes unless needed, but we override that.

René