Skip to contentSkip to conversation

Fixing a parse error for a SmPL position variable constraint

cocci Markus Elfring 2 participants 5 messages Feb 13, 2024 – Feb 14, 2024

lore
Share & tools
lore
#0 lore raw

Hello,

I hope that you would like to take another look at a script variant (like the following) for the semantic patch language also together with the software combination “Coccinelle 1.1.1-00676-g99513ec1”.

@find@
position p1, p2;
statement s1, s2;
@@
if@p1 (...)

 {
    ... when any
    s1
    s2
 }
 ... when any
 if@p2 (...)
 {
    ... when any
    s1
    s2

}

@duplicated_code@
position find.p1, find.p2;
position pos != find.p2;
statement s1, s2;
@@
*if@p1@pos (...)
*{
... when any
* s1
* s2
*}
... when any
*if@p2 (...)
*{
... when any
* s1
* s2
*}

Temporary test result:
Markus_Elfring@Sonne:…/Projekte/Coccinelle/janitor> spatch --parse-cocci show_same_statements7z.cocci …
meta: parse error:
File "show_same_statements7z.cocci", line 21, column 21, charpos = 226
around = 'p2',
whole content = position pos != find.p2;

Will more desirable analyses become possible by similar source code search approaches?

Regards,
Markus

#1 lore raw
Quoted 23 lines · Markus Elfring

Hello,

I hope that you would like to take another look at a script variant (like the following) for the semantic patch language also together with the software combination “Coccinelle 1.1.1-00676-g99513ec1”.

@find@
position p1, p2;
statement s1, s2;
@@
if@p1 (...)

 {
    ... when any
    s1
    s2
 }
 ... when any
 if@p2 (...)
 {
    ... when any
    s1
    s2
Quoted 5 lines

}

@duplicated_code@
position find.p1, find.p2;
position pos != find.p2;

Try switching the above two lines.

julia

Quoted 31 lines

statement s1, s2;
@@
*if@p1@pos (...)
*{
... when any
* s1
* s2
*}
... when any
*if@p2 (...)
*{
... when any
* s1
* s2
*}

Temporary test result:
Markus_Elfring@Sonne:…/Projekte/Coccinelle/janitor> spatch --parse-cocci show_same_statements7z.cocci …
meta: parse error:
File "show_same_statements7z.cocci", line 21, column 21, charpos = 226
around = 'p2',
whole content = position pos != find.p2;

Will more desirable analyses become possible by similar source code search approaches?

Regards,
Markus

#2 lore raw
Quoted 4 lines
Quoted 2 lines

position find.p1, find.p2;
position pos != find.p2;

Try switching the above two lines.

Did you try this SmPL code adjustment out already in your test environment?

Markus_Elfring@Sonne:…/Projekte/Coccinelle/janitor> spatch --parse-cocci show_same_statements7w-20240214.cocci …
Variable find.p2 in duplicated_code cannot be used as both a position and a constraint

How does this error message (from the software combination “Coccinelle 1.1.1-00687-g0df3efff”) fit to the discussed data processing intention?

Regards,
Markus

#3 lore raw
Quoted 11 lines · Markus Elfring
Quoted 4 lines
Quoted 2 lines

position find.p1, find.p2;
position pos != find.p2;

Try switching the above two lines.

Did you try this SmPL code adjustment out already in your test environment?

Markus_Elfring@Sonne:…/Projekte/Coccinelle/janitor> spatch --parse-cocci show_same_statements7w-20240214.cocci …
Variable find.p2 in duplicated_code cannot be used as both a position and a constraint

OK, I guess it is not allowed. Actually, the semantics of positive an negative uses of a position variable is quite different, so it seems that it is not allowed to use both at once.

But it should be possible to use two position variables at the original place.

julia

Quoted 8 lines

How does this error message (from the software combination “Coccinelle 1.1.1-00687-g0df3efff”) fit to the discussed data processing intention?

Regards,
Markus

#4 lore raw
Quoted 7 lines
Quoted 3 lines

Markus_Elfring@Sonne:…/Projekte/Coccinelle/janitor> spatch --parse-cocci show_same_statements7w-20240214.cocci …
Variable find.p2 in duplicated_code cannot be used as both a position and a constraint

OK, I guess it is not allowed. Actually, the semantics of positive an negative uses of a position variable is quite different, so it seems that it is not allowed to use both at once.

Do we stumble on a target conflict here?

Quoted 1 line

But it should be possible to use two position variables at the original place.

Would you like to adjust affected software components accordingly?

Regards,
Markus