Module Caveat_mem.Make.WP


module WP: sig .. end

module F: Caveat_fol
Implementation of a specific Formula.S for Caveat
module D1: Datalib.Create(F)
module Shared: Hoare_lib.Create(D1)
Library functions from Hoare model
module CavLib: sig .. end
Library functions for Caveat memory model implemented in Caveat_mem.
module Model: sig .. end
val top_loc_term : F.data -> D1.pointer
include struct ... end

type mem = {
   label : Clabels.c_label;
   variables : F.var Cil_datatype.Varinfo.Hashtbl.t;
}
type frame = {
   kf : Kernel_function.t;
   mutable states : (Clabels.c_label * mem) list;
   mutable result : F.var option;
   mutable exit_status : F.var option;
   return : Cil_types.typ option;
}

Environement management


val global_frame : unit -> frame
val new_frame : Kernel_function.t ->
m_here:mem option ->
m_pre:mem option ->
m_post:mem option ->
F.var option -> frame
val mem_at : frame -> Clabels.c_label -> mem
gives the memory state for that label. Create it if it doesn't exist.
val result : frame -> F.var * Cil_types.typ
val exit_status : frame -> F.var
val set_exit_status : frame ->
F.var -> frame
val get_exit_status : frame -> F.var option
val get_var : mem -> Cil_types.varinfo -> F.fvar
Get the wp variable of the C variable. With create, create it if it doesn't exist.
Raises Not_found when create=false and the variable doesn't exist.

Build data and operations on locations



Data for locations


val null : F.data
val base_address : 'a -> F.data -> F.data
val cvar : 'a -> Shared.Globals.t -> F.data
val field : F.data -> Cil_types.fieldinfo -> F.data
val index : F.data ->
'a -> F.dterm -> F.data
val shift : F.data ->
'a -> F.dterm -> F.data
val startof : F.data -> 'a -> F.data

see also indir in "Operations on pointers"
val var_data : mem -> Cil_types.varinfo -> F.data
val var_data_term : mem -> Cil_types.varinfo -> F.dterm

Operations on pointers


val indir : mem ->
F.data -> F.dterm
d should be a data that represent an adddress:
Returns the data representing the content of d in m.
val check_indir_label : Clabels.c_label -> F.data -> unit
We want to read d at label, but in Caveat model, everything comes from variables, so we cannot read at a label if the address is evaluated at another one... Check that the data d is compatible with the label, and
Raises Unsupported otherwise.
val load : mem ->
Ctypes.c_object -> F.data -> value
val block_length : 'a ->
F.data -> Formula.integer D1.F.term
val disj : F.data ->
F.data -> D1.F.pred
val cast_loc_to_loc : Cil_types.typ -> Cil_types.typ -> 'a -> 'b

Anti-aliasing


val direct_lval : F.data -> bool
Returns true when there is no indirect access in d. (Notice that there can be indirect access in subexpressions such as indexes)
val logic_data : F.data -> bool
val add_unique : ('a -> 'a -> bool) -> 'a -> 'a list -> 'a list
TODOopt should we have oredered lists ?
val get_read_addr : bool -> F.pred -> F.data list
Collect the addresses of locations read by p.
with_direct : says if we have to include base addresses (@X).
val prepare_guard : F.data ->
F.pred -> F.pred

WP calculus



Substitutions


val mk_mu : mem ->
F.data ->
Cil_types.varinfo *
(F.data -> F.data) *
(F.data ->
F.dterm option -> F.dterm option)
Returns (v, mu) where v is the variable to substitute (base of lval), and mu the expression of its new value after and assignment lval = exp; Extended version of Hoare similar function mk_mu. See doc there.

f_mu can be used with a None expression.

val get_var_and_mu : mem ->
loc ->
'a F.term ->
F.fvar * F.dterm option
val subst : frame ->
loc -> 'a F.term -> D.F.pred -> D.F.pred
val subst_lval : frame ->
'a -> loc -> value -> D.F.pred -> F.pred
val subst_result : frame -> value option -> D.F.pred -> D.F.pred
val update_at_label : frame ->
Clabels.c_label -> F.pred -> F.pred
Substitute the variables that represent values at label by the variables that represent values at Here.

Quantification


val create_data_name : F.data -> unit
Create names for address variables, field, structure types... Needed so that they will be declared. Be careful: not recursive, has to be used in a recursive function
val quantify_at_label : frame ->
Clabels.c_label -> F.pred -> D.F.pred

declaration of local variables


val local_scope : 'a -> 'b -> Mcfg.scope -> 'c -> 'c

Zones


val valid : 'a -> F.data D.assigned -> D1.F.pred
val separated : F.data D.assigned ->
F.data D.assigned -> D1.F.pred

Zones


type m_dzone 
type dzone = m_dzone F.term 
val tau_of_dzone : Formula.tau
val dzone_assigned : 'a -> 'b
val dzone_subset : 'a -> 'b -> 'c
val dzone_union : 'a -> 'b -> 'c
val dzone_empty : unit -> 'a
val dzone_of_var : 'a -> 'b -> 'c
val effect_supported : bool

Regions


type region 
val pp_region : 'a -> 'b -> unit
val region_assigned : 'a -> 'b
val region_empty : 'a -> 'b
val region_union : 'a -> 'b -> 'c
val region_included : 'a -> 'b -> 'c
val region_separated : 'a -> 'b -> 'c
val region_fingerprint : 'a -> 'b -> 'c
val region_supported : bool
val ctype_of_data : F.data -> Cil_types.typ
Try to find the data type needed to generated 'format' for indir and mu_indir
val subst_havoc : frame ->
F.data D.assigned -> D.havoc list
val assigns_goal : 'a -> 'b -> 'c -> 'd
val assigns_supported : bool

User Predicate environment

This is not correct at the moment because closures are based on variables, and they should be based on data. For instance :
type closure = Cil_types.varinfo * string 
val pp_closure : Format.formatter -> Cil_types.varinfo * string -> unit
val userdef_frame : 'a -> frame
val userdef_signature : frame ->
'a ->
'b ->
F.var list *
(Cil_datatype.Varinfo.Hashtbl.key * string) list
val userdef_closure : mem ->
Cil_types.varinfo * 'a -> F.dterm
val label_at_closure : 'a * 'b -> 'b