On Wed, 17 Jun 2020, Johannes Berg wrote:

> Hi spatchers,
>
> I've been working on an old code base, and toying with something like
> this:
>
> @@
> type T;
> identifier x;
> expression E, F;
> @@
> {
> +T x;

Change the + to ++

There is no guarantee on the order in which the variables will appear.

> +
>  E;
> ...

Add when any after the ...

julia

> -T x;
> ...
> }
>
> (and also a variant with "T x = F;" where F is an expression).
>
>
> That works OK if there's only a single variable, but...
>
> First, it only moves a single variable up, even if I run it multiple
> times (I think)?
>
> Secondly, sometimes it says something like:
>
> previous modification:
>
>   <<< T x;
>
> CONTEXT
> According to environment 2:
>    rule starting on line 15.x -> id var1
>    rule starting on line 15.T -> u32
>
> current modification:
>
>   <<< T x;
>
> CONTEXT
> According to environment 2:
>    rule starting on line 15.x -> id var2
>    rule starting on line 15.T -> u32
>
> EXN:Failure("rule starting on line 15: already tagged token:\nC code 
> context\nFile \"/tmp/cocci_small_output-170001-6edb7c.c\", line 150, column 
> 4,  charpos = 8969\n    around = 'DEBUG_PRINT', whole content =     
> DEBUG_PRINT(...omitted...);")
>
>
> That's basically what I saw, something like
>
> DEBUG_PRINT(...);
> u32 var1 = ...;
> u32 var2 = ...;
>
>
> Any ideas how I can make it move more variable declarations up?
>
> Thanks,
> johannes
>
> _______________________________________________
> 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