[inferbo] Renamed a few Itv values

Reviewed By: jvillard

Differential Revision: D5137445

fbshipit-source-id: f16b68e
master
Mehdi Bouaziz 8 years ago committed by Facebook Github Bot
parent 43d7428e8f
commit 1486b92084

@ -36,7 +36,7 @@ struct
type extras = Typ.Procname.t -> Procdesc.t option type extras = Typ.Procname.t -> Procdesc.t option
let set_uninitialized (typ : Typ.t) loc mem = match typ.desc with let set_uninitialized (typ : Typ.t) loc mem = match typ.desc with
| Tint _ | Tfloat _ -> Dom.Mem.weak_update_heap loc Dom.Val.top_itv mem | Tint _ | Tfloat _ -> Dom.Mem.weak_update_heap loc Dom.Val.Itv.top mem
| _ -> mem | _ -> mem
(* NOTE: heuristic *) (* NOTE: heuristic *)
@ -78,13 +78,13 @@ struct
let model_natual_itv : (Ident.t * Typ.t) option -> Dom.Mem.astate -> Dom.Mem.astate let model_natual_itv : (Ident.t * Typ.t) option -> Dom.Mem.astate -> Dom.Mem.astate
= fun ret mem -> = fun ret mem ->
match ret with match ret with
| Some (id, _) -> Dom.Mem.add_stack (Loc.of_id id) Dom.Val.nat_itv mem | Some (id, _) -> Dom.Mem.add_stack (Loc.of_id id) Dom.Val.Itv.nat mem
| _ -> mem | _ -> mem
let model_unknown_itv : (Ident.t * Typ.t) option -> Dom.Mem.astate -> Dom.Mem.astate let model_unknown_itv : (Ident.t * Typ.t) option -> Dom.Mem.astate -> Dom.Mem.astate
= fun ret mem -> = fun ret mem ->
match ret with match ret with
Some (id, _) -> Dom.Mem.add_stack (Loc.of_id id) Dom.Val.top_itv mem Some (id, _) -> Dom.Mem.add_stack (Loc.of_id id) Dom.Val.Itv.top mem
| None -> mem | None -> mem
let model_infer_print let model_infer_print
@ -236,7 +236,7 @@ struct
let ret_val = Dom.Mem.find_heap ret_loc callee_exit_mem in let ret_val = Dom.Mem.find_heap ret_loc callee_exit_mem in
Dom.Val.subst ret_val subst_map Dom.Val.subst ret_val subst_map
|> Dom.Val.normalize (* normalize bottom *) |> Dom.Val.normalize (* normalize bottom *)
| _ -> Dom.Val.top_itv | _ -> Dom.Val.Itv.top
let print_debug_info : Sil.instr -> Dom.Mem.astate -> Dom.Mem.astate -> unit let print_debug_info : Sil.instr -> Dom.Mem.astate -> Dom.Mem.astate -> unit
= fun instr pre post -> = fun instr pre post ->

@ -265,17 +265,9 @@ struct
let get_all_locs : t -> PowLoc.t let get_all_locs : t -> PowLoc.t
= fun x -> PowLoc.join x.powloc (get_array_locs x) = fun x -> PowLoc.join x.powloc (get_array_locs x)
let top_itv : t let of_itv itv = { bot with itv }
= { bot with itv = Itv.top }
let pos_itv : t let of_int n = of_itv (Itv.of_int n)
= { bot with itv = Itv.pos }
let nat_itv : t
= { bot with itv = Itv.nat }
let of_int : int -> t
= fun n -> { bot with itv = Itv.of_int n }
let of_itv : Itv.t -> t let of_itv : Itv.t -> t
= fun itv -> { bot with itv } = fun itv -> { bot with itv }
@ -286,9 +278,6 @@ struct
let of_array_blk : ArrayBlk.astate -> t let of_array_blk : ArrayBlk.astate -> t
= fun a -> { bot with arrayblk = a } = fun a -> { bot with arrayblk = a }
let zero : t
= of_int 0
let modify_itv : Itv.t -> t -> t let modify_itv : Itv.t -> t -> t
= fun i x -> { x with itv = i } = fun i x -> { x with itv = i }
@ -414,6 +403,14 @@ struct
let pp_summary : F.formatter -> t -> unit let pp_summary : F.formatter -> t -> unit
= fun fmt x -> F.fprintf fmt "(%a, %a)" Itv.pp x.itv ArrayBlk.pp x.arrayblk = fun fmt x -> F.fprintf fmt "(%a, %a)" Itv.pp x.itv ArrayBlk.pp x.arrayblk
module Itv =
struct
let nat = of_itv Itv.nat
let m1_255 = of_itv Itv.m1_255
let pos = of_itv Itv.pos
let top = of_itv Itv.top
end
end end
module Stack = module Stack =
@ -478,7 +475,7 @@ struct
let find : Loc.t -> astate -> Val.t let find : Loc.t -> astate -> Val.t
= fun l m -> = fun l m ->
try find l m with try find l m with
| Not_found -> Val.top_itv | Not_found -> Val.Itv.top
let find_set : PowLoc.t -> astate -> Val.t let find_set : PowLoc.t -> astate -> Val.t
= fun locs mem -> = fun locs mem ->

@ -24,9 +24,9 @@ struct
let eval_const : Const.t -> Val.t let eval_const : Const.t -> Val.t
= function = function
| Const.Cint intlit -> (try Val.of_int (IntLit.to_int intlit) with _ -> Val.top_itv) | Const.Cint intlit -> (try Val.of_int (IntLit.to_int intlit) with _ -> Val.Itv.top)
| Const.Cfloat f -> f |> int_of_float |> Val.of_int | Const.Cfloat f -> f |> int_of_float |> Val.of_int
| _ -> Val.top_itv (* TODO *) | _ -> Val.Itv.top (* TODO *)
let sizeof_ikind : Typ.ikind -> int let sizeof_ikind : Typ.ikind -> int
= function = function
@ -170,7 +170,7 @@ struct
| Exp.Sizeof {nbytes=Some size} -> Val.of_int size | Exp.Sizeof {nbytes=Some size} -> Val.of_int size
| Exp.Sizeof {typ; nbytes=None} -> Val.of_int (sizeof typ) | Exp.Sizeof {typ; nbytes=None} -> Val.of_int (sizeof typ)
| Exp.Exn _ | Exp.Exn _
| Exp.Closure _ -> Val.top_itv | Exp.Closure _ -> Val.Itv.top
and eval_unop : Unop.t -> Exp.t -> Mem.astate -> Location.t -> Val.t and eval_unop : Unop.t -> Exp.t -> Mem.astate -> Location.t -> Val.t
= fun unop e mem loc -> = fun unop e mem loc ->
@ -252,7 +252,7 @@ struct
let v = Mem.find_heap lv mem in let v = Mem.find_heap lv mem in
let itv_v = let itv_v =
if Itv.is_bot (Val.get_itv v) then Itv.bot else if Itv.is_bot (Val.get_itv v) then Itv.bot else
Val.get_itv Val.zero Itv.false_sem
in in
let v' = Val.modify_itv itv_v v in let v' = Val.modify_itv itv_v v in
Mem.update_mem (PowLoc.singleton lv) v' mem Mem.update_mem (PowLoc.singleton lv) v' mem
@ -431,6 +431,6 @@ struct
in in
let formals = get_formals callee_pdesc in let formals = get_formals callee_pdesc in
let actuals = List.map ~f:(fun (a, _) -> eval a caller_mem loc) params in let actuals = List.map ~f:(fun (a, _) -> eval a caller_mem loc) params in
list_fold2_def ~default:Val.top_itv ~f:add_pair formals actuals ~init:[] list_fold2_def ~default:Val.Itv.top ~f:add_pair formals actuals ~init:[]
|> subst_map_of_pairs |> subst_map_of_pairs
end end

@ -189,7 +189,6 @@ let pp_min_max : F.formatter -> min_max_t -> unit
| Min -> F.fprintf fmt "min" | Min -> F.fprintf fmt "min"
| Max -> F.fprintf fmt "max" | Max -> F.fprintf fmt "max"
let pp : F.formatter -> t -> unit let pp : F.formatter -> t -> unit
= fun fmt -> function = fun fmt -> function
| MInf -> F.fprintf fmt "-oo" | MInf -> F.fprintf fmt "-oo"
@ -207,6 +206,14 @@ let pp : F.formatter -> t -> unit
let of_int : int -> t let of_int : int -> t
= fun n -> Linear (n, SymLinear.empty) = fun n -> Linear (n, SymLinear.empty)
let zero = of_int 0
let one = of_int 1
let minus_one = of_int ~-1
let _255 = of_int 255
let of_sym : SymLinear.t -> t let of_sym : SymLinear.t -> t
= fun s -> Linear (0, s) = fun s -> Linear (0, s)
@ -536,8 +543,9 @@ struct
let pp : F.formatter -> t -> unit let pp : F.formatter -> t -> unit
= fun fmt (l, u) -> F.fprintf fmt "[%a, %a]" Bound.pp l Bound.pp u = fun fmt (l, u) -> F.fprintf fmt "[%a, %a]" Bound.pp l Bound.pp u
let of_int : int -> t let of_bound bound = (bound, bound)
= fun n -> (Bound.of_int n, Bound.of_int n)
let of_int n = of_bound (Bound.of_int n)
let get_new_sym : Typ.Procname.t -> t let get_new_sym : Typ.Procname.t -> t
= fun pname -> = fun pname ->
@ -551,29 +559,23 @@ struct
let upper = Bound.of_sym (SymLinear.make pname (i+1)) in let upper = Bound.of_sym (SymLinear.make pname (i+1)) in
(lower, upper) (lower, upper)
let top : t let m1_255 = (Bound.minus_one, Bound._255)
= (Bound.MInf, Bound.PInf)
let pos : t let nat = (Bound.zero, Bound.PInf)
= (Bound.of_int 1, Bound.PInf)
let nat : t let one = of_bound Bound.one
= (Bound.of_int 0, Bound.PInf)
let zero : t let pos = (Bound.one, Bound.PInf)
= of_int 0
let one : t let top = (Bound.MInf, Bound.PInf)
= of_int 1
let zero = of_bound Bound.zero
let true_sem : t let true_sem = one
= one
let false_sem : t let false_sem = zero
= zero
let unknown_bool : t let unknown_bool = join false_sem true_sem
= (Bound.of_int 0, Bound.of_int 1)
let is_true : t -> bool let is_true : t -> bool
= fun (l, u) -> Bound.le (Bound.of_int 1) l || Bound.le u (Bound.of_int (-1)) = fun (l, u) -> Bound.le (Bound.of_int 1) l || Bound.le u (Bound.of_int (-1))
@ -869,20 +871,21 @@ let is_finite : t -> bool
| NonBottom x -> ItvPure.is_finite x | NonBottom x -> ItvPure.is_finite x
| Bottom -> false | Bottom -> false
let zero : t let false_sem = NonBottom ItvPure.false_sem
= of_int 0
let one : t let m1_255 = NonBottom ItvPure.m1_255
= of_int 1
let nat = NonBottom ItvPure.nat
let one = NonBottom ItvPure.one
let pos = NonBottom ItvPure.pos
let pos : t let true_sem = NonBottom ItvPure.true_sem
= NonBottom ItvPure.pos
let nat : t let unknown_bool = NonBottom ItvPure.unknown_bool
= NonBottom ItvPure.nat
let unknown_bool : t let zero = NonBottom ItvPure.zero
= NonBottom ItvPure.unknown_bool
let make : Bound.t -> Bound.t -> t let make : Bound.t -> Bound.t -> t
= fun l u -> if Bound.lt u l then Bottom else NonBottom (ItvPure.make l u) = fun l u -> if Bound.lt u l then Bottom else NonBottom (ItvPure.make l u)

Loading…
Cancel
Save