Skip to contentSkip to conversation

Adjusting applicability of “block markers” (for SmPL)?

cocci Markus Elfring 1 participant 1 message Jun 19, 2025

lore
Share & tools
lore
#0 lore raw

Hello,

The application of “iterators” (or “block markers”) can trigger special software development challenges (because the source code search specification shares properties according to function definitions).
Some of them can be indicated by test cases like the following.

A)
SmPL script example:
@compound_display@
statement list sl;
@@
do_something(...)
{
*sl
}

Corresponding test result example:
Markus_Elfring@Sonne:…/Projekte/Coccinelle/Probe> time /usr/bin/spatch show_something_as_function_with_compound_statement.cocci return_test_value.c …
@@ -1,5 +1,4 @@
char do_something (int context)
{
- return MY_TEST;
}

real    0m0,419s
user    0m0,052s
sys     0m0,061s

B)
The SmPL declaration “iterator name do_something;” can be added to the previous example.

Another test result example:
Markus_Elfring@Sonne:…/Projekte/Coccinelle/Probe> time /usr/bin/spatch show_something_with_compound_statement.cocci return_test_value2.c …
@@ -1,7 +1,6 @@
int do_another_thing (char input)
{do_something(1)
{
- return MY_TEST2;
}
return 5;
}

real    0m0,068s
user    0m0,037s
sys     0m0,031s

How can a collection of such “iterators” (or “block markers”) become a general part of the Coccinelle system configuration for a selected source code base (so that parsing of involved source files can usually succeed)?

Regards,
Markus