On Wed, 17 Apr 2019, Markus Elfring wrote:

> Hello,
>
> I have tried another small SmPL script out.
>
>
> @replacement@
> expression ex;
> identifier var;
> @@
>  var
> -   = var +
> +   +=
>             ex
>
>
> elfring@Sonne:~/Projekte/Coccinelle/Probe> spatch simplify_addition1.cocci 
> Test_increment1.c
> …
> @@ -1,6 +1,6 @@
>  int main(void)
>  {
>  int counter = 3;
> -counter = counter + 5;
> +counter += 5;
>  return counter;
>  }
>
>
> I have repeated this transformation approach with the following source code.
>
>
> int main(void)
> {
> int x = 2, y = 3;
> x = y + 5;
> return x;
> }

A metavariable is always bound to the same value within a given
control-flow path.  I have no idea what you are trying to get at with
this example.

julia

>
>
> This test example did not present a generated change suggestion.
> I find that such a result can be interpreted in two ways then.
>
> 1. The Coccinelle software ensured that the specified metavariable “var”
>    referred to the same source code at all shown places with the consequence
>    that the variable “y” could not match in this test case.
>
> 2. A possible data output was not displayed despite of the detail
>    that the variable “y” is also an identifier according to the syntax of
>    the C programming language.
>    Would there be a need to express a relationship to a previous match
>    by a kind of notation for backreferences?
>
>
> The situation can become challenging for the safe handling of advanced
> statements in more meaningful source files.
>
> * How do you think about to help with the reconsideration
>   (and occasional deletion) of duplicate code by the means of
>   the semantic patch language?
>
> * Would you like to clarify the desired software behaviour for such use cases?
>
> Regards,
> Markus
> _______________________________________________
> Cocci mailing list
> [email protected]
> https://systeme.lip6.fr/mailman/listinfo/cocci
>
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to