Re: [cocci] Adjusting attributes for variables with SmPL?
Julia Lawall <[email protected]> Sat, 30 May 2026 11:17:30 +0200 (CEST)
| Newsgroups | fr.inria.cocci |
|---|---|
| Message-ID | <[email protected]> |
This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-1305099527-1780132650=:3990 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT On Sat, 30 May 2026, Markus Elfring wrote: > >> Another data processing approach might look promising. > >> > >> @searching@ > >> expression E1, E2; > >> identifier F, X; > >> initialiser I; > >> type T; > >> @@ > >> T F = I; > >> ... > >> memcmp(&F.X, E1, E2) > >> > >> @script:python generation@ > >> x << searching.X; > >> my_string; > >> @@ > >> coccinelle.my_string = "\"" + x + "\"" > >> > >> @replacement@ > >> expression searching.E1, searching.E2; > >> identifier searching.F, searching.X, generation.my_string; > >> initialiser searching.I; > >> type searching.T; > >> @@ > >> T > >> +__attribute__((myattr( > >> +my_string > >> +))) > >> F = I; > >> ... > >> memcmp(&F.X, E1, E2) > > How interesting is it if a source code attribute gets constructed by Python (and/or OCaml) or SmPL code? > > Will the applied data parsing algorithms trigger any further development considerations? > > > >> Markus_Elfring@Sonne:…/elfring/Projekte/Coccinelle/Probe> /usr/bin/spatch --parse-cocci suggestion4_for_Pierrick_Philippe-20260528.cocci > >> … > >> @replacement@ > >> @@ > >> > >> T > >> >>> __attribute__ ((myattr(my_string))) > >> F = I ; > >> ... > >> > >> memcmp(&F.X, E1, E2) > >> > >> > >> warning: replacement: inherited metavariable my_string not used in the -, +, or context code > >> … > … > > What message? The question is whether it makes the change that is wanted? > > See also: > https://gitlab.inria.fr/coccinelle/coccinelle/-/blame/1bff7651118fc65c269dd8dba7f7d4a30fbc72c7/parsing_cocci/check_meta.ml#LC901 > > > > Maybe the check for whether variables are used doesn't look in arrtibute > > arguments. > Would any adjustments be expected for the implementation of a function like “check_all_marked”? > https://gitlab.inria.fr/coccinelle/coccinelle/-/blob/1bff7651118fc65c269dd8dba7f7d4a30fbc72c7/parsing_cocci/check_meta.ml#L852-861 check_meta.ml has been updated. julia --8323329-1305099527-1780132650=:3990--