Re: [cocci] Adjusting attributes for variables with SmPL?

Pierrick Philippe <[email protected]> Tue, 26 May 2026 11:24:04 +0200
Newsgroups fr.inria.cocci
Message-ID <[email protected]>
Hi Markus,

Thanks for your answers.

On 5/26/26 11:20, Markus Elfring wrote:
>>> Also, Coccinelle requires you specify a complete term, not just the
>>> subpart of the term that is convenient for you.
>> I think I understand, also I do have a question regarding the `declaration` keyword of the grammar.
>> Is there any way to access inner information of the declaration?
> The programming interfaces can eventually be adjusted.
>
> The semantic patch language supports also kinds of metavariables which refer to compound data.
> It would occasionally be nice if subitems would be directly accessible.
>
> But it is possible to express desirable information requirements by the means of SmPL conjunctions.
> https://gitlab.inria.fr/coccinelle/coccinelle/-/blob/1bff7651118fc65c269dd8dba7f7d4a30fbc72c7/docs/manual/cocci_syntax.tex#L1050-1054
>
> SmPL conjunctions trigger the need to indicate data constraints in a repeated way.
Oh, thank you for the pointers into the documentation.
>>> This again fails because you have only specified part of the memcmp
>>> statement.  If you want to put a complete statement, you have to put the
>>> whole thing.  I think you can also just put a memcmp call, without the
>>> semicolon.
>> It worked with the whole `memcmp` call statement indeed, I probably misunderstood the `...` operator then.
> Did you interpret SmPL ellipses as code placeholders?

It is exactly how I interpreted it, somehow such as `.*` in regular
expression.

Thanks,

Pierrick