I believe it would be something like

Cil.Instr([Cil.Call(None, Cil.Lval (Var v, NoOffset), [Const
Int64.zero], loc)]) ->
  if v.name = "exit" then
    ...here we know we have an exit(0) statement...

That is, "exit(0)" is treated as a function call.

--Stephen

On Tue, Jul 14, 2009 at 4:36 AM, ThanhVu (Vu)
Nguyen<nguyenthanh...@gmail.com> wrote:
>   The example that Chris gave includes Break, Return etc ... just wondering
> what about exist  ?  e.g.,    what Cil.skind would match this statement
> exit (0);  ?   Thanks
>
>
> VN -
>
>
> On Wed, Jul 8, 2009 at 1:45 AM, ThanhVu (Vu) Nguyen
> <nguyenthanh...@gmail.com> wrote:
>>
>> Ah these are very helpful  , I will take a look at them tomorrow morning
>> -- thank you for the quick reply !
>> VN -
>>
>>
>> On Wed, Jul 8, 2009 at 1:35 AM, Christoph Spiel <csp...@freenet.de> wrote:
>>>
>>> Hi Vu,
>>>
>>> On Wed, Jul 08, 2009 at 12:39:22AM -0600, ThanhVu (Vu) Nguyen wrote:
>>> > Hi, can I find out what kind of statement  (e.g., a single statement,
>>> >  a
>>> > block of statements, etc) from a given Cil.stmtkind?
>>>
>>>        To distinguish between the kinds of
>>> statments (Instr, Return, Goto, etc.) you can
>>> just use "match" with the appropriate value.
>>> Here is one of my statement visitors:
>>>
>>>  method vstmt (a_statement: Cil.stmt): Cil.stmt Cil.visitAction =
>>>    begin
>>>      match a_statement.Cil.skind with
>>>          Cil.Instr _instruction_list -> ()
>>>        | Cil.Return (optional_expression, location) ->
>>>            begin
>>>              match optional_expression with
>>>                  Some expression ->
>>>                    Trace.trace trace_identifier
>>>                      (Pretty.dprintf "+ vstmt: expression = %a\n"
>>> Cil.dn_exp expression);
>>>                    self#traverse expression location
>>>                | None -> ()
>>>            end
>>>        | Cil.Goto (_statement_ref, _location) -> ()
>>>        | Cil.Break _location -> ()
>>>        | Cil.Continue _location -> ()
>>>        | Cil.If (expression, _if_block, _else_block, location) ->
>>>            Trace.trace trace_identifier
>>>              (Pretty.dprintf "+ vstmt: expression = %a\n" Cil.dn_exp
>>> expression);
>>>            self#traverse expression location
>>>        | Cil.Switch (expression, _block, _statement_list, location) ->
>>>            Trace.trace trace_identifier
>>>              (Pretty.dprintf "+ vstmt: expression = %a\n" Cil.dn_exp
>>> expression);
>>>            self#traverse expression location
>>>        | Cil.Loop (_block, _location, _opt_statement1, _opt_statement2)
>>> -> ()
>>>        | Cil.Block _block -> ()
>>>        | Cil.TryFinally (_block1, _block2, _location) -> ()
>>>        | Cil.TryExcept (_block1, _, _block2, _location) -> ()
>>>    end;
>>>    Cil.DoChildren
>>>
>>>
>>> > For example if my Cil.stmtkind c has the content {a single
>>> > statement} vs c has the content {a; block; of; many; statements;}?
>>>
>>>        A "match" on a Cil.stmtkind (as shown
>>> above) dissects all statement kinds so that you
>>> can take care of them.  For the case of
>>> Cil.Blocks you could look at the length of the
>>> statement list inside of it, like, e.g.,
>>>    List.length a_block.Cil.bstmts
>>>
>>>
>>> HTH,
>>>        Chris
>>>
>>> --
>>> Dr. Christoph L. Spiel
>>
>
>
> ------------------------------------------------------------------------------
> 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
>
>

------------------------------------------------------------------------------
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

Reply via email to