--- layout: fc_discuss_archives title: Message 22 from Frama-C-discuss on March 2012 ---
Hello, I have a piece of code that modifies the AST quite well now, but it gives rise to two comments/questions. -My code doesn't do any analysis whatsoever after the instrumentation I do in the AST, so I'm not sure that doing the modifications on a new AST from a new project is necessary. From the small examples I've been using, it really seems okay to modify the original AST (on which the analysis's been performed) in place, but I'm not sure it's not only because I've been (un)lucky with my examples? -In my instrumentation, I want (need) to declare temporary variables at the block level and be able to use these variables right after in the new instructions I'm creating. There doesn't seem to be an easy way to do this and what I'm doing now is more of a dirty hack: I'm using the vinst and vblock visitors; if I use Cil.makeLocalVar in vinst only, the variable is never actually put in the block declarations (at least not with any of the parameters I tried for this function), so I create a placeholder in vinst by using Cil.makeVarinfo, and I maintain a stack of variables to declare, and do all the corresponding makeLocalVar calls in the "post" function of vblock (using ChangeDoChildrenPost), which otherwise does nothing. Now this seems to work sometimes, but it fairly regularly fails to add the variable declarations in the blocks. What's odd is that it seems to fail when other local declarations are missing, like e.g. in the case highlighted in bug report #1113. So I'm not sure if my hack *should* work all the time and doesn't because of a more complex issue, or if I'm just lucky that it works sometimes but really shouldn't (and then I would need to do the declarations in some other way)? Cheers, Pierre