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

Pierrick Philippe <[email protected]> Thu, 28 May 2026 10:16:09 +0200
Newsgroups fr.inria.cocci
Message-ID <[email protected]>
On 5/28/26 09:44, Markus Elfring wrote:
>>>> My use case is a plugin to GCC where I use this attribute to identify variables of interest for a specific analysis. To be even more precise, its purpose is to identify variables (or types) that are known to hold secret data (cryptographically speaking) in order to run static analysis to detect misuses of such data (e.g., a call to memcmp).
>>> Would further programming interfaces be helpful for source code introspection?
>> Yeah, I came out with the idea of a configuration file where the
>> variables/types/parameters of interest are listed per files (and maybe
>> scope?) alongside a python script to generate the different semantic
>> patch to be used with Coccinelle.
>> At first, I was thinking about writing a custom clang-tool for doing it
>> from the configuration file, but then I remembered that Coccinelle was
>> completely doing the same job and is also a tool coming for public
>> research.
> Further data structures can be designed and reused as needed.
>
> APIs from mentioned compilers might become also more interesting occasionally.
Indeed, but the thing is more expensive in term of maintainability.
In the clang-tools case, the API tends to change quite rapidly.
>> The idea of the configuration file is to be able to leave the code base
>> untouched, while still being able to play along with our tool.
> This is obviously possible.
>>>> The idea to use Coccinelle here is to be able to patch the source code of huge code base in order to run our analysis.
>>> This approach triggers special development challenges.
>> What do you mean?
> You are struggling to become more familiar with the supported capabilities
> of the semantic patch language for example.
>
> There are development ideas which are waiting on further collateral evolution.
> https://github.com/coccinelle/coccinelle/issues/
> https://gitlab.inria.fr/coccinelle/coccinelle/-/issues

Oh right, thanks.

Pierrick

> Regards,
> Markus