--- layout: fc_discuss_archives title: Message 7 from Frama-C-discuss on March 2012 ---
Hello, I'm trying to see how it is possible to modify a Cil AST to insert "new code" in the source that's being processed. More precisely, from a statement like e.g. funk(a, b, c); I'd like to get something like <some statements generated by my plugin> <some local variable declarations...> funk(a,b,c); <some statements...> The plugin I'm working currently does code insertion by simply printing out a patch, but this doesn't quite seem to work for post-call statements in some cases. So, that's why I'd like to do all those inserts directly in the AST (pretty much in the way Frama-C currently expands some pieces of code I guess?), so that I could get the modified code by doing something like "frama-c -meplugin -print somecode.c". Now I'm not sure how to do that properly (hence this email): I considered doing the modifications by redefining a vstmt_aux in a generic visitor, but I'm not sure this should work (I did a quick few tests, and it doesn't seem that inserting new statements will have them printed by frama-c, although they're taken into account by the subsequent analysis done on the AST). Can someone give me pointers to where this sort of code exists in Frama-C or to how to do this thing properly? Cheers, Pierre