Module InferIR.Sil
Programs and Types
type if_kind=|Ik_bexpboolean expressions, and exp ? exp : exp
|Ik_dowhile|Ik_for|Ik_if|Ik_land_lorobtained from translation of && or ||
|Ik_while|Ik_switchKind of prune instruction
type instr_metadata=|Abstract of InferBase.Location.ta good place to apply abstraction, mostly used in the biabduction analysis
|ExitScope of Var.t list * InferBase.Location.tremove temporaries and dead program variables
|Nullify of Pvar.t * InferBase.Location.tnullify stack variable
|Skipno-op
|VariableLifetimeBegins of Pvar.t * Typ.t * InferBase.Location.tstack variable declared
val compare_instr_metadata : instr_metadata -> instr_metadata -> int
type instr=|Load of Ident.t * Exp.t * Typ.t * InferBase.Location.tLoad a value from the heap into an identifier.
x = *lexp:typwherelexpis an expression denoting a heap addresstypis the root type oflexp.|Store of Exp.t * Typ.t * Exp.t * InferBase.Location.tStore the value of an expression into the heap.
*lexp1:typ = exp2wherelexp1is an expression denoting a heap addresstypis the root type oflexp1exp2is the expression whose value is stored.|Prune of Exp.t * InferBase.Location.t * bool * if_kindprune the state based on
exp=1, the boolean indicates whether true branch|Call of Ident.t * Typ.t * Exp.t * (Exp.t * Typ.t) list * InferBase.Location.t * CallFlags.tCall ((ret_id, ret_typ), e_fun, arg_ts, loc, call_flags)represents an instructionret_id = e_fun(arg_ts);|Metadata of instr_metadatahints about the program that are not strictly needed to understand its semantics, for instance information about its original syntactic structure
An instruction.
val equal_instr : instr -> instr -> boolval skip_instr : instrval instr_is_auxiliary : instr -> boolCheck if an instruction is auxiliary, or if it comes from source instructions.
type offset=|Off_fld of Typ.Fieldname.t * Typ.t|Off_index of Exp.tOffset for an lvalue.
Components of Propositions
type atom=|Aeq of Exp.t * Exp.tequality
|Aneq of Exp.t * Exp.tdisequality
|Apred of PredSymb.t * Exp.t listpredicate symbol applied to exps
|Anpred of PredSymb.t * Exp.t listnegated predicate symbol applied to exps
an atom is a pure atomic formula
type lseg_kind=|Lseg_NEnonempty (possibly circular) listseg
|Lseg_PEpossibly empty (possibly circular) listseg
kind of lseg or dllseg predicates
type zero_flag= bool optionThe boolean is true when the pointer was dereferenced without testing for zero.
type null_case_flag= boolTrue when the value was obtained by doing case analysis on null in a procedure call.
type inst=|Iabstraction|Iactual_precondition|Ialloc|Iformal of zero_flag * null_case_flag|Iinitial|Ilookup|Inone|Inullify|Irearrange of zero_flag * null_case_flag * int * PredSymb.path_pos|Itaint|Iupdate of zero_flag * null_case_flag * int * PredSymb.path_pos|Ireturn_from_call of intinstrumentation of heap values
val equal_inst : inst -> inst -> boolval inst_actual_precondition : instval inst_formal : instval inst_initial : instfor formal parameters and heap values at the beginning of the function
val inst_lookup : instfor initial values
val inst_none : instval inst_nullify : instval inst_rearrange : bool -> InferBase.Location.t -> PredSymb.path_pos -> instthe boolean indicates whether the pointer is known nonzero
val inst_update : InferBase.Location.t -> PredSymb.path_pos -> instval inst_set_null_case_flag : inst -> instSet the null case flag of the inst.
val inst_new_loc : InferBase.Location.t -> inst -> instupdate the location of the instrumentation
type 'inst strexp0=|Eexp of Exp.t * 'instBase case: expression with instrumentation
|Estruct of (Typ.Fieldname.t * 'inst strexp0) list * 'instC structure
|Earray of Exp.t * (Exp.t * 'inst strexp0) list * 'instArray of given length There are two conditions imposed / used in the array case. First, if some index and value pair appears inside an array in a strexp, then the index is less than the length of the array. For instance, x |->
10 | e1: v1implies that e1 <= 9. Second, if two indices appear in an array, they should be different. For instance, x |->10 | e1: v1, e2: v2implies that e1 != e2.structured expressions represent a value of structured type, such as an array or a struct.
val compare_strexp : ?inst:bool -> strexp -> strexp -> intComparison function for strexp. The inst:: parameter specifies whether instumentations should also be considered (false by default).
val equal_strexp : ?inst:bool -> strexp -> strexp -> boolEquality function for strexp. The inst:: parameter specifies whether instumentations should also be considered (false by default).
type 'inst hpred0=|Hpointsto of Exp.t * 'inst strexp0 * Exp.trepresents
exp|->strexp:typexpwheretypexpis an expression representing a type, e.h.sizeof(t).|Hlseg of lseg_kind * 'inst hpara0 * Exp.t * Exp.t * Exp.t listhigher - order predicate for singly - linked lists. Should ensure that exp1!= exp2 implies that exp1 is allocated. This assumption is used in the rearrangement. The last
exp listparameter is used to denote the shared links by all the nodes in the list.|Hdllseg of lseg_kind * 'inst hpara_dll0 * Exp.t * Exp.t * Exp.t * Exp.t * Exp.t listhigher-order predicate for doubly-linked lists. Parameter for the higher-order singly-linked list predicate. Means "lambda (root,next,svars). Exists evars. body". Assume that root, next, svars, evars are disjoint sets of primed identifiers, and include all the free primed identifiers in body. body should not contain any non - primed identifiers or program variables (i.e. pvars).
an atomic heap predicate
and 'inst hpara0={root : Ident.t;next : Ident.t;svars : Ident.t list;evars : Ident.t list;body : 'inst hpred0 list;}and 'inst hpara_dll0={cell : Ident.t;address cell
blink : Ident.t;backward link
flink : Ident.t;forward link
svars_dll : Ident.t list;evars_dll : Ident.t list;body_dll : 'inst hpred0 list;}parameter for the higher-order doubly-linked list predicates. Assume that all the free identifiers in body_dll should belong to cell, blink, flink, svars_dll, evars_dll.
val compare_hpred0 : ('inst -> 'inst -> int) -> 'inst hpred0 -> 'inst hpred0 -> intval compare_hpara0 : ('inst -> 'inst -> int) -> 'inst hpara0 -> 'inst hpara0 -> intval compare_hpara_dll0 : ('inst -> 'inst -> int) -> 'inst hpara_dll0 -> 'inst hpara_dll0 -> intval compare_hpred0 : ('inst -> 'inst -> int) -> 'inst hpred0 -> 'inst hpred0 -> intval compare_hpara0 : ('inst -> 'inst -> int) -> 'inst hpara0 -> 'inst hpara0 -> intval compare_hpara_dll0 : ('inst -> 'inst -> int) -> 'inst hpara_dll0 -> 'inst hpara_dll0 -> intval compare_hpred0 : ('inst -> 'inst -> int) -> 'inst hpred0 -> 'inst hpred0 -> intval compare_hpara0 : ('inst -> 'inst -> int) -> 'inst hpara0 -> 'inst hpara0 -> intval compare_hpara_dll0 : ('inst -> 'inst -> int) -> 'inst hpara_dll0 -> 'inst hpara_dll0 -> int
val compare_hpred : ?inst:bool -> hpred -> hpred -> intComparison function for hpred. The inst:: parameter specifies whether instumentations should also be considered (false by default).
val equal_hpred : ?inst:bool -> hpred -> hpred -> boolEquality function for hpred. The inst:: parameter specifies whether instumentations should also be considered (false by default).
module HpredSet : InferStdlib.IStd.Caml.Set.S with type HpredSet.elt = hpredSets of heap predicates
Compaction
val create_sharing_env : unit -> sharing_envCreate a sharing env to store canonical representations
val hpred_compact : sharing_env -> hpred -> hpredReturn a compact representation of the exp
val is_objc_object : hpred -> boolComparision And Inspection Functions
val is_static_local_name : string -> Pvar.t -> boolCheck if a pvar is a local static in objc
val is_block_pvar : Pvar.t -> boolCheck if a pvar is a local pointing to a block in objc
Pretty Printing
val color_wrapper : InferStdlib.Pp.env -> F.formatter -> 'a -> f:(InferStdlib.Pp.env -> F.formatter -> 'a -> unit) -> unitWraps a printing function with an updated printenv when using diff printing
val pp_exp_printenv : ?print_types:bool -> InferStdlib.Pp.env -> F.formatter -> Exp.t -> unitPretty print an expression.
val d_exp : Exp.t -> unitdump an expression.
val pp_texp : InferStdlib.Pp.env -> F.formatter -> Exp.t -> unitPretty print a type.
val pp_texp_full : InferStdlib.Pp.env -> F.formatter -> Exp.t -> unitPretty print a type with all the details.
val d_texp_full : Exp.t -> unitDump a type expression with all the details.
val d_exp_list : Exp.t list -> unitDump a list of expressions.
val pp_offset : InferStdlib.Pp.env -> F.formatter -> offset -> unitval d_offset_list : offset list -> unitDump a list of offsets
val location_of_instr : instr -> InferBase.Location.tGet the location of the instruction
val if_kind_to_string : if_kind -> stringPretty print an if_kind
val pp_instr_metadata : InferStdlib.Pp.env -> F.formatter -> instr_metadata -> unitval pp_instr : print_types:bool -> InferStdlib.Pp.env -> F.formatter -> instr -> unitPretty print an instruction.
val d_instr : instr -> unitDump an instruction.
val pp_atom : InferStdlib.Pp.env -> F.formatter -> atom -> unitPretty print an atom.
val d_atom : atom -> unitDump an atom.
val pp_sexp : InferStdlib.Pp.env -> F.formatter -> strexp -> unitPretty print a strexp.
val d_sexp : strexp -> unitDump a strexp.
val pp_hpred : InferStdlib.Pp.env -> F.formatter -> hpred -> unitPretty print a hpred.
val d_hpred : hpred -> unitDump a hpred.
val pp_hpara : InferStdlib.Pp.env -> F.formatter -> hpara -> unitPretty print a hpara.
val pp_hpara_dll : InferStdlib.Pp.env -> F.formatter -> hpara_dll -> unitPretty print a hpara_dll.
module Predicates : sig ... endModule Predicates records the occurrences of predicates as parameters of (doubly -)linked lists and Epara. Provides unique numbering for predicates and an iterator.
val pp_hpred_env : InferStdlib.Pp.env -> Predicates.env option -> F.formatter -> hpred -> unitPretty print a hpred with optional predicate env
Functions for traversing SIL data types
val strexp_expmap : ((Exp.t * inst option) -> Exp.t * inst option) -> strexp -> strexpChange exps in strexp using
f. WARNING: the result might not be normalized.
val hpred_expmap : ((Exp.t * inst option) -> Exp.t * inst option) -> hpred -> hpredChange exps in hpred by
f. WARNING: the result might not be normalized.
val hpred_list_expmap : ((Exp.t * inst option) -> Exp.t * inst option) -> hpred list -> hpred listChange exps in hpred list by
f. WARNING: the result might not be normalized.
val atom_expmap : (Exp.t -> Exp.t) -> atom -> atomChange exps in atom by
f. WARNING: the result might not be normalized.
val hpred_list_get_lexps : (Exp.t -> bool) -> hpred list -> Exp.t listval hpred_entries : hpred -> Exp.t listval atom_free_vars : atom -> Ident.t InferStdlib.IStd.Sequence.tval atom_gen_free_vars : atom -> (unit, Ident.t) InferStdlib.IStd.Sequence.Generator.tval hpred_free_vars : hpred -> Ident.t InferStdlib.IStd.Sequence.tval hpred_gen_free_vars : hpred -> (unit, Ident.t) InferStdlib.IStd.Sequence.Generator.tval hpara_shallow_free_vars : hpara -> Ident.t InferStdlib.IStd.Sequence.tval hpara_dll_shallow_free_vars : hpara_dll -> Ident.t InferStdlib.IStd.Sequence.tVariables in hpara_dll, excluding bound vars in the body
Substitution
val subst_of_list : (Ident.t * Exp.t) list -> substCreate a substitution from a list of pairs. For all (id1, e1), (id2, e2) in the input list, if id1 = id2, then e1 = e2.
val subst_of_list_duplicates : (Ident.t * Exp.t) list -> substlike subst_of_list, but allow duplicate ids and only keep the first occurrence
val sub_empty : substThe empty substitution.
val is_sub_empty : subst -> boolval sub_join : subst -> subst -> substCompute the common id-exp part of two inputs
subst1andsubst2. The first component of the output is this common part. The second and third components are the remainder ofsubst1andsubst2, respectively.
val sub_symmetric_difference : subst -> subst -> subst * subst * substCompute the common id-exp part of two inputs
subst1andsubst2. The first component of the output is this common part. The second and third components are the remainder ofsubst1andsubst2, respectively.
val sub_find : (Ident.t -> bool) -> subst -> Exp.tsub_find filter subreturns the expression associated to the first identifier that satisfiesfilter. RaiseNot_foundif there isn't one.
val sub_filter : (Ident.t -> bool) -> subst -> substsub_filter filter subrestricts the domain ofsubto the identifiers satisfyingfilter.
val sub_filter_pair : subst -> f:((Ident.t * Exp.t) -> bool) -> substsub_filter_exp filter subrestricts the domain ofsubto the identifiers satisfyingfilter(id, sub(id)).
val sub_range_partition : (Exp.t -> bool) -> subst -> subst * substsub_range_partition filter subpartitionssubaccording to whether range expressions satisfyfilter.
val sub_domain_partition : (Ident.t -> bool) -> subst -> subst * substsub_domain_partition filter subpartitionssubaccording to whether domain identifiers satisfyfilter.
val sub_domain : subst -> Ident.t listReturn the list of identifiers in the domain of the substitution.
val sub_range_map : (Exp.t -> Exp.t) -> subst -> substsub_range_map f subappliesfto the expressions in the range ofsub.
val sub_map : (Ident.t -> Ident.t) -> (Exp.t -> Exp.t) -> subst -> substsub_map f g subapplies the renamingfto identifiers in the domain ofsuband the substitutiongto the expressions in the range ofsub.
val extend_sub : subst -> Ident.t -> Exp.t -> subst optionExtend substitution and return
Noneif not possible.
val subst_free_vars : subst -> Ident.t InferStdlib.IStd.Sequence.tval subst_gen_free_vars : subst -> (unit, Ident.t) InferStdlib.IStd.Sequence.Generator.t
Functions for replacing occurrences of expressions.
Functions for constructing or destructing entities in this module
val sigma_to_sigma_ne : hpred list -> (atom list * hpred list) listval hpara_instantiate : hpara -> Exp.t -> Exp.t -> Exp.t list -> Ident.t list * hpred listhpara_instantiate para e1 e2 elistinstantiatesparawithe1,e2andelist. Ifpara = lambda (x, y, xs). exists zs. b, then the result of the instantiation isb[e1 / x, e2 / y, elist / xs, _zs'/ zs]for some fresh_zs'.
val hpara_dll_instantiate : hpara_dll -> Exp.t -> Exp.t -> Exp.t -> Exp.t list -> Ident.t list * hpred listhpara_dll_instantiate para cell blink flink elistinstantiatesparawithcell,blink,flink, andelist. Ifpara = lambda (x, y, z, xs). exists zs. b, then the result of the instantiation isb[cell / x, blink / y, flink / z, elist / xs, _zs'/ zs]for some fresh_zs'.
val custom_error : Pvar.t