On Tue, Jul 14, 2009 at 05:19:52PM -0400, Stephen Magill wrote: > Cil.Instr([Cil.Call(None, Cil.Lval (Var v, NoOffset), [Const > Int64.zero], loc)]) -> > if v.name = "exit" then ... ^^^ there is a typo here, it's v.vname
This could be rewritten: Cil.Instr([Cil.Call(None, Cil.Lval (Var v, NoOffset), [Const Int64.zero], loc)]) when v.vname = "exit" -> ... Or, even shorter, using pattern-matching on variants: Cil.Instr([Cil.Call(None, Cil.Lval (Var {vname = "exit"}, NoOffset), [Const Int64.zero], loc)]) -> ... It might be safer to use the following, though: Cil.Instr l when List.mem (function Cil.Call(None, Cil.Lval (Var {vname = "exit"}, NoOffset), [Const Int64.zero], loc) -> true | _ -> false ) l -> ... This will find every list of instructions containing (at any point) "exit(0);". Of course, the safest way to handle "exit(0)" is at the instruction level, using the vinst method, but it depends on what you want to do with it. method vinst = function | Cil.Call(None, Cil.Lval (Var {vname = "exit"}, NoOffset), [Const Int64.zero], loc) -> ... | _ -> SkipChildren Last but not least, you should really put "open Cil" on the first line of your module, and get rid of those "Cil." which clutter the code. Regards, -- Gabriel Kerneis ------------------------------------------------------------------------------ Enter the BlackBerry Developer Challenge This is your chance to win up to $100,000 in prizes! For a limited time, vendors submitting new applications to BlackBerry App World(TM) will have the opportunity to enter the BlackBerry Developer Challenge. See full prize details at: http://p.sf.net/sfu/Challenge _______________________________________________ CIL-users mailing list CIL-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/cil-users