IR.Procdesc
module NodeKey : sig ... end
module Node : sig ... end
node of the control flow graph
module IdMap : IStdlib.PrettyPrintable.PPMap with type key = Node.id
Map with node id keys.
module NodeHashSet : IStdlib.HashSet.S with type elt = Node.t
Hash set with nodes as keys.
procedure descriptions
val append_locals : t -> ProcAttributes.var_data list -> unit
append a list of new local variables to the existing list of local variables
val compute_distance_to_exit_node : t -> unit
Compute the distance of each node to the exit node, if not computed already
val create_node :
t ->
IBase.Location.t ->
Node.nodekind ->
Sil.instr list ->
Node.t
Create a new cfg node with the given location, kind, list of instructions, and add it to the procdesc.
val create_node_from_not_reversed :
t ->
IBase.Location.t ->
Node.nodekind ->
Instrs.not_reversed_t ->
Node.t
fold over all nodes and their instructions
val from_proc_attributes : ProcAttributes.t -> t
Use Cfg.create_proc_desc
if you are adding a proc desc to a cfg
val get_access : t -> ProcAttributes.access
Return the visibility attribute
val get_attributes : t -> ProcAttributes.t
Get the attributes of the procedure.
val set_attributes : t -> ProcAttributes.t -> unit
val get_captured : t -> CapturedVar.t list
Return name and type of block's captured variables
val get_formals : t -> (Mangled.t * Typ.t * Annot.Item.t) list
Return name, type, and annotation of formal parameters
Return pvar and type of formal parameters that are passed by value
Return pvar and type of formal parameters that are passed by reference
Return pvar and type of formal parameters that are passed as pointer, i.e. T*
val get_loc : t -> IBase.Location.t
Return loc information for the procedure
val get_locals : t -> ProcAttributes.var_data list
Return name and type and attributes of local variables
is_local pdesc pvar
is true
iff pvar
is a local variable of pdesc
. This function performs a linear search on the local variables of pdesc
.
Similar to is_local
, but returns true
when pvar
is a non-structured-binding local variable or a formal variable of pdesc
.
val get_proc_name : t -> Procname.t
Return the return param type of the procedure, which is found from formals
val get_static_callees : t -> Procname.t list
get a list of unique static callees excluding self
val is_defined : t -> bool
Return true
iff the procedure is defined, and not just declared
val is_java_synchronized : t -> bool
Return true
if the procedure signature has the Java synchronized keyword
val is_csharp_synchronized : t -> bool
Return true
if the procedure is synchronized via a C# lock
iterate over all nodes and their instructions
Map and replace the instructions to be executed. Returns true if at least one substitution occured.
val replace_instrs_using_context :
t ->
f:(Node.t -> 'a -> Sil.instr -> Sil.instr) ->
update_context:('a -> Sil.instr -> 'a) ->
context_at_node:(Node.t -> 'a) ->
bool
Map and replace the instructions to be executed using a context that we built with previous instructions in the node. Returns true if at least one substitution occured.
val replace_instrs_by_using_context :
t ->
f:(Node.t -> 'a -> Sil.instr -> Sil.instr array) ->
update_context:('a -> Sil.instr -> 'a) ->
context_at_node:(Node.t -> 'a) ->
bool
Like replace_instrs_using_context
, but slower, and each instruction may be replaced by 0, 1, or more instructions.
fold over all the nodes of a procedure
Set the successor nodes and exception nodes, if given, and update predecessor links
Set the successor nodes and exception nodes, and update predecessor links
val init_wto : t -> unit
val get_wto : t -> Node.t WeakTopologicalOrder.Partition.t
val pp_signature : Stdlib.Format.formatter -> t -> unit
val pp_local : Stdlib.Format.formatter -> ProcAttributes.var_data -> unit
val pp_with_instrs : ?print_types:bool -> Stdlib.Format.formatter -> t -> unit
val is_specialized : t -> bool
true if pvar is a captured variable of a cpp lambda or obcj block
true if var is a captured variable of a cpp lambda or obcj block
val size : t -> int
Return number of nodes, plus number of instructions (in nodes), plus number of edges (between nodes).
val is_too_big : IBase.Checker.t -> max_cfg_size:int -> t -> bool
Check if the CFG of the procedure is too big to analyze. If it is too big, it logs an internal error and returns true.
module SQLite : IBase.SqliteUtils.Data with type t = t option
per-procedure CFGs are stored in the SQLite "procedures" table as NULL if the procedure has no CFG
val load : Procname.t -> t option
CFG for the given proc name. None
when the source code for the procedure was not captured (eg library code or code outside of the project root). NOTE: To query the procedure's attributes (eg return type, formals, ...), prefer the cheaper Attributes.load
. Attributes can be present even when the source code is not.
val load_exn : Procname.t -> t
like load
, but raises an exception if no procdesc is available.
val load_uid : ?capture_only:bool -> string -> t option
like load
but takes a database key for the procedure directly (generated from Procname.to_unique_id
) and optionally only looks inside the capture database