> @@ > 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, ...) ...+> ) } julia _______________________________________________ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci