> Use position variables and use a second rule that forces the positions to
> be different.  I already explained this.

I suggest to take another look at the provided information.

I have extended the analysis approach like the following.


@find@
identifier work;
position p1, p2;
statement s1, s2;
type T;
@@
 T work(...)
 {
 ... when any
 if@p1 (...)
 {
    ... when any
    s1
    s2
 }
 ... when any
 if@p2 (...)
 {
    ... when any
    s1
    s2
 }
 ... when any
 }

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


> You surely don't like it, but nothing is going to change in this direction,
> so the discussion (at least on my side) ends here.

Now I stumble on another error message.


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



By the way:
Will it matter that the determined source code positions are not only different
but also that one place should be before the other?

Regards,
Markus
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to