From: Benjamin Y. <ben...@fa...> - 2015-02-07 20:00:04
|
> On Feb 5, 2015, at 8:53 AM, Gabriel Kerneis <ga...@ke...> wrote: > > Le 2015-02-05 14:59, Benjamin Ylvisaker a écrit : >> >> Sorry for being too concise. I don’t have a misbehaving test. Here >> is what’s causing my confusion in a little more detail: >> >> - The slocals field of fundec is a list of varinfos. I assume this >> represents the set of local variables used in the function. >> - varinfos include the unique id field. >> - The copyFunctionVisitor class makes new varinfos with new ids (for >> the old function? See bug 143). >> - I don’t see where slocals is changed anywhere. >> >> So won’t both copies’ slocals refer to the same set of varinfos? Is >> that not actually a problem for some reason? > > The CIL visitor semantics is a bit tricky to follow at times, but I don't think there is a bug here. > > ChangeDoChildrenPost in vfunc: > https://github.com/cil-project/cil/blob/d9d6a08b8017dea996f3f6a4eef07dc017682d6d/src/cil.ml#L6451 <https://github.com/cil-project/cil/blob/d9d6a08b8017dea996f3f6a4eef07dc017682d6d/src/cil.ml#L6451> > will eventually trigger the invoke of visitCilFunction, which in turns iterates over the formals: > https://github.com/cil-project/cil/blob/d9d6a08b8017dea996f3f6a4eef07dc017682d6d/src/cil.ml#L5590 <https://github.com/cil-project/cil/blob/d9d6a08b8017dea996f3f6a4eef07dc017682d6d/src/cil.ml#L5590> > which calls the vvdec method: > https://github.com/cil-project/cil/blob/d9d6a08b8017dea996f3f6a4eef07dc017682d6d/src/cil.ml#L5497 <https://github.com/cil-project/cil/blob/d9d6a08b8017dea996f3f6a4eef07dc017682d6d/src/cil.ml#L5497> > > And vvdec for copyFunction does the right thing of allocating new locals: > https://github.com/cil-project/cil/blob/d9d6a08b8017dea996f3f6a4eef07dc017682d6d/src/cil.ml#L6463 <https://github.com/cil-project/cil/blob/d9d6a08b8017dea996f3f6a4eef07dc017682d6d/src/cil.ml#L6463> > > Don't hesitate if you have further questions. Thanks for the explanation. The part in childrenFunction is what I was missing. Ben |