Module Kernel_function


module Kernel_function: sig .. end
Operations on kernel function.
Consult the Plugin Development Guide for additional details.

Kernel functions are comparable and hashable


type t = Db_types.kernel_function 
val compare : t -> t -> int
val equal : t -> t -> bool
val hash : t -> int
module Datatype: Project.Datatype.S  with type t = kernel_function
Datatype for a kernel function.

Searching


val find_from_sid : int -> Cil_types.stmt * t
Return the stmt and its kernel function from its identifier. Complexity: the first call to this function is linear in the size of the cil file.
Raises Not_found if there is no statement with such an identifier.
Consult the Plugin Development Guide for additional details.
exception No_Statement
val find_first_stmt : t -> Cil_types.stmt
Find the first statement in a kernel function.
Raises No_Statement if there is no first statement for the given function.
val find_return : t -> Cil_types.stmt
Find the return statement of a kernel function.
val find_label : t -> string -> Cil_types.stmt Pervasives.ref
Find a given label in a kernel function.
Raises Not_found if the label does not exist in the given function.
val find_enclosing_block : Cil_types.stmt -> Cil_types.block
returns the innermost block to which the given statement belongs.
val find_all_enclosing_blocks : Cil_types.stmt -> Cil_types.block list
same as above, but returns all enclosing blocks, starting with the innermost one.
val blocks_closed_by_edge : Cil_types.stmt -> Cil_types.stmt -> Cil_types.block list
edge_exits_block kf s1 s2 returns the (possibly empty) list of blocks that are closed when going from s1 to s2.
Raises Invalid_argument if the statements do not belong to the same function or are not adjacent in the cfg.

Checkers


val is_definition : t -> bool
val returns_void : t -> bool

Getters


val dummy : unit -> t
val get_vi : t -> Cil_types.varinfo
val get_id : t -> int
val get_name : t -> string
val get_type : t -> Cil_types.typ
val get_return_type : t -> Cil_types.typ
val get_location : t -> Cil_types.location
val get_global : t -> Cil_types.global
val get_formals : t -> Cil_types.varinfo list
val get_locals : t -> Cil_types.varinfo list
exception No_Definition
val get_definition : t -> Cil_types.fundec
Raises No_Definition if the given function is not a definition.

Membership of variables


val is_formal : Cil_types.varinfo -> t -> bool
Return true if the given varinfo is a formal parameter of the given function. If possible, use this function instead of Ast_info.Function.is_formal.
val is_local : Cil_types.varinfo -> t -> bool
Return true if the given varinfo is a local variable of the given function. If possible, use this function instead of Ast_info.Function.is_local.
val is_formal_or_local : Cil_types.varinfo -> t -> bool
Return true if the given varinfo is a formal parameter or a local variable of the given function. If possible, use this function instead of Ast_info.Function.is_formal_or_local.

Specifications


val get_spec : t -> Cil_types.funspec
val postcondition : t -> Cil_types.predicate Cil_types.named
val precondition : t -> Cil_types.predicate Cil_types.named
val populate_spec : (t -> unit) Pervasives.ref
Should not be used by casual users.

Collections


module Make_Table: 
functor (Data : Project.Datatype.S) ->
functor (Info : Signature.NAME_SIZE_DPDS) -> Computation.HASHTBL_OUTPUT with type key = t and type data = Data.t
Hashtable indexed by kernel functions and dealing with project.
module Set: sig .. end
Set of kernel functions.
module Queue: sig .. end
Datatype for a queue of kernel functions.

Setters

Use carefully the following functions.

val register_stmt : t -> Cil_types.stmt -> Cil_types.block list -> unit
Register a new statement in a kernel function, with the list of blocks that contain the statement (innermost first)

Pretty printer


val pretty_name : Format.formatter -> t -> unit
Print the name of a kernel function.