On Thu, 2 Apr 2015, ron minnich wrote:
> This is not working with my 1.0.0-rc21 on ubuntu, is there a version you'd > recommend? The current release is rc24, but I don't think there is anything relevant that is new, except the global idea. Does it crash, or just not find anything? Could you send the exact semantic patch and some representative C code? thanks, julia > > Many thanks! > > ron > > On Thu, Apr 2, 2015 at 2:22 PM Julia Lawall <[email protected]> wrote: > > f(...){ > > + Mach *m = machp(); > > ... > > x = m > > ... > > } > > This requires there to be exactly one occurrence of x = m on > every (non > failing) execution path. > > > > > The x = m could also be m->x, or if (m) s, and so on > > Do you just mean any reference to m at all? Or do you mean any > reference > that is not an assignment to m, ie not m = x. > > If you want to allow any kind of reference to m, you could do: > > @r exists@ > typedef Mach; // only needed once per semantic patch > idexpression Mach *m; > function f; > position p; > @@ > f@p(...){ > <+... > m > ...+> > } > > @@ > identifier r.f; > position r.p; > idexpression Mach *r.m; > @@ > > f@p(...) { > ++Mach *m; > ... > } > > There could be more than one Mach * typed variable in a > function. The ++ > lets them all get added, but there is no way to know in what > order they > will appear. > > Otherwise, the idea here is that if there ever exists an m in > the > function, then add the declaration to the function. It might be > possible > to merge the two rules, as: > > @r exists@ > typedef Mach; // only needed once per semantic patch > idexpression Mach *m; > function f; > @@ > f(...){ > ++ Mach *m; > <+... > m > ...+> > } > > But that might give multiple declarations of the same variable, > if it is > used in more than one execution path. > > Also, it might be possible to say global idexpression Mach *m. > I don't > remember if that is in the current release or in the upcoming > one. > > julia > > >
_______________________________________________ Cocci mailing list [email protected] https://systeme.lip6.fr/mailman/listinfo/cocci
