On Thu, May 27, 2021 at 12:44 PM Julia Lawall <julia.law...@inria.fr> wrote: > > > @@ > > expression a, b; > > identifier vcpu; > > fresh identifier vcpu_ctxt = vcpu ## "_ctxt"; > > iterator name kvm_for_each_vcpu; > > identifier fc; > > @@ > > kvm_for_each_vcpu(a, vcpu, b) > > { > > /* hop over any declarations */ > > + vcpu_ctxt = &vcpu->arch.ctxt; > > <+... > > fc(..., vcpu, ...) > > ...+> > > } > > > > So I'm trying to add the line "vcpu_ctxt = &vcpu->arch.ctxt" after any > > declarations, only if there's a function in that block that's using > > vcpu. This works, but the vcpu_ctxt assignment is of course always > > added first, before any declarations. > > > > Doing the following partially works, but it of course misses the case > > where the function call with vcpu comes immediately after the > > vcpu_ctxt assignment. Removing S2 altogether gives me a parse error. > > > > @@ > > expression a, b; > > identifier vcpu; > > fresh identifier vcpu_ctxt = vcpu ## "_ctxt"; > > iterator name kvm_for_each_vcpu; > > identifier fc; > > statement S1, S2; > > @@ > > kvm_for_each_vcpu(a, vcpu, b) > > { > > ... when != S1 > > + vcpu_ctxt = &vcpu->arch.ctxt; > > S2; > > <+... > > fc(..., vcpu, ...) > > ...+> > > } > > @@ > identifier f; > statement S1,S2; > @@ > > f(...) { > ... when != S1 > ( > + new_code > S2 > ... when any > & > <+... > fc(..., vcpu, ...) > ...+> > ) > }
I get a parse error when I try that (both copying it verbatim, or adapting it to my code): minus: parse error: File "test.cocci", line 18, column 0, charpos = 209 around = '<+...', whole content = <+... Thanks! /fuad > > julia _______________________________________________ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci