more consistency with abbreviated functions names in abstract domain signature

Reviewed By: dkgi

Differential Revision: D3012533

fb-gh-sync-id: 89d749c
shipit-source-id: 89d749c
master
Sam Blackshear 10 years ago committed by Facebook Github Bot 9
parent edbd7854b2
commit 730a2afaaf

@ -12,47 +12,47 @@ module F = Format
module type AbstractDomain = sig module type AbstractDomain = sig
type astate type astate
val init : astate (* the initial state *) val initial : astate
val bot : astate val bottom : astate
val is_bot : astate -> bool val is_bottom : astate -> bool
val lteq : lhs:astate -> rhs:astate -> bool (* fst \sqsubseteq snd? *) val (<=) : lhs:astate -> rhs:astate -> bool (* fst \sqsubseteq snd? *)
val join : astate -> astate -> astate val join : astate -> astate -> astate
val widen : prev:astate -> next:astate -> num_iters:int -> astate val widen : prev:astate -> next:astate -> num_iters:int -> astate
val pp : F.formatter -> astate -> unit val pp : F.formatter -> astate -> unit
end end
module BotLiftedAbstractDomain (A : AbstractDomain) : AbstractDomain = struct module BottomLiftedAbstractDomain (A : AbstractDomain) : AbstractDomain = struct
type astate = type astate =
| Bot | Bottom
| NonBot of A.astate | NonBottom of A.astate
let bot = Bot let bottom = Bottom
let is_bot astate = let is_bottom astate =
astate = Bot astate = Bottom
let init = NonBot A.init let initial = NonBottom A.initial
let lteq ~lhs ~rhs = match lhs, rhs with let (<=) ~lhs ~rhs = match lhs, rhs with
| Bot, _ -> true | Bottom, _ -> true
| _ , Bot -> false | _ , Bottom -> false
| NonBot lhs, NonBot rhs -> A.lteq ~lhs ~rhs | NonBottom lhs, NonBottom rhs -> A.(<=) ~lhs ~rhs
let join astate1 astate2 = let join astate1 astate2 =
match astate1, astate2 with match astate1, astate2 with
| Bot, _ -> astate2 | Bottom, _ -> astate2
| _, Bot -> astate1 | _, Bottom -> astate1
| NonBot a1, NonBot a2 -> NonBot (A.join a1 a2) | NonBottom a1, NonBottom a2 -> NonBottom (A.join a1 a2)
let widen ~prev ~next ~num_iters = let widen ~prev ~next ~num_iters =
match prev, next with match prev, next with
| Bot, _ -> next | Bottom, _ -> next
| _, Bot -> prev | _, Bottom -> prev
| NonBot prev, NonBot next -> NonBot (A.widen ~prev ~next ~num_iters) | NonBottom prev, NonBottom next -> NonBottom (A.widen ~prev ~next ~num_iters)
let pp fmt = function let pp fmt = function
| Bot -> F.fprintf fmt "_|_" | Bottom -> F.fprintf fmt "_|_"
| NonBot astate -> A.pp fmt astate | NonBottom astate -> A.pp fmt astate
end end

@ -36,7 +36,7 @@ module Make
let old_state = M.find node_id inv_map in let old_state = M.find node_id inv_map in
let widened_post = let widened_post =
A.widen ~prev:old_state.post ~next:astate_post ~num_iters:old_state.visit_count in A.widen ~prev:old_state.post ~next:astate_post ~num_iters:old_state.visit_count in
if A.lteq ~lhs:widened_post ~rhs:old_state.post if A.(<=) ~lhs:widened_post ~rhs:old_state.post
then then
begin begin
L.out "Old state contains new, not adding succs@."; L.out "Old state contains new, not adding succs@.";
@ -65,7 +65,7 @@ module Make
let join_pred astate_acc pred_id = let join_pred astate_acc pred_id =
let pred_state = M.find pred_id inv_map in let pred_state = M.find pred_id inv_map in
A.join pred_state.post astate_acc in A.join pred_state.post astate_acc in
let astate_pre = IList.fold_left join_pred A.bot visited_preds in let astate_pre = IList.fold_left join_pred A.bottom visited_preds in
let inv_map', work_queue'' = exec_node node astate_pre work_queue' inv_map in let inv_map', work_queue'' = exec_node node astate_pre work_queue' inv_map in
exec_worklist work_queue'' inv_map' exec_worklist work_queue'' inv_map'
| None -> inv_map | None -> inv_map
@ -74,7 +74,7 @@ module Make
L.out "Starting analysis of %a@." Procname.pp (Cfg.Procdesc.get_proc_name pdesc); L.out "Starting analysis of %a@." Procname.pp (Cfg.Procdesc.get_proc_name pdesc);
let cfg = C.from_pdesc pdesc in let cfg = C.from_pdesc pdesc in
let start_node = C.start_node cfg in let start_node = C.start_node cfg in
let inv_map', work_queue' = exec_node start_node A.init (S.empty cfg) M.empty in let inv_map', work_queue' = exec_node start_node A.initial (S.empty cfg) M.empty in
exec_worklist work_queue' inv_map' exec_worklist work_queue' inv_map'
end end

@ -25,15 +25,15 @@ module PathCountDomain = struct
then Top then Top
else PathCount c else PathCount c
let bot = make_path_count 0 let bottom = make_path_count 0
let init = make_path_count 1 let initial = make_path_count 1
let is_bot = function let is_bottom = function
| PathCount c -> c = 0 | PathCount c -> c = 0
| Top -> false | Top -> false
let lteq ~lhs ~rhs = match lhs, rhs with let (<=) ~lhs ~rhs = match lhs, rhs with
| PathCount c1, PathCount c2 -> c1 <= c2 | PathCount c1, PathCount c2 -> c1 <= c2
| _, Top -> true | _, Top -> true
| Top, PathCount _ -> false | Top, PathCount _ -> false

@ -157,7 +157,7 @@ module Make
try try
let state = M.find node_id inv_map in let state = M.find node_id inv_map in
state.post state.post
with Not_found -> A.bot in with Not_found -> A.bottom in
let post_str = pp_to_string A.pp node_id_post in let post_str = pp_to_string A.pp node_id_post in
if inv_str <> post_str then if inv_str <> post_str then
let error_msg = let error_msg =

Loading…
Cancel
Save