[inferbo] Refactor 3/8: model_by_value without model_env

Reviewed By: jvillard

Differential Revision: D7397120

fbshipit-source-id: 1b8ac4e
master
Mehdi Bouaziz 7 years ago committed by Facebook Github Bot
parent 90b5600c8f
commit 672fd3a9a5

@ -246,24 +246,23 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
mem mem
| Prune (exp, _, _, _) -> | Prune (exp, _, _, _) ->
Sem.prune exp mem Sem.prune exp mem
| Call (ret, Const Cfun callee_pname, params, location, _) | Call (ret, Const Cfun callee_pname, params, location, _) -> (
-> ( match Models.Call.dispatch callee_pname params with
let model_env = Models.mk_model_env callee_pname node location tenv ?ret in | Some {Models.exec} ->
match Models.Call.dispatch callee_pname params with let model_env = Models.mk_model_env callee_pname node location tenv ?ret in
| Some {Models.exec} -> exec model_env mem
exec model_env mem | None ->
match Summary.read_summary pdesc callee_pname with
| Some summary ->
let callee = extras callee_pname in
instantiate_mem tenv ret callee callee_pname params mem summary location
| None -> | None ->
match Summary.read_summary pdesc callee_pname with L.(debug BufferOverrun Verbose)
| Some summary -> "/!\\ Unknown call to %a at %a@\n" Typ.Procname.pp callee_pname Location.pp
let callee = extras callee_pname in location ;
instantiate_mem tenv ret callee callee_pname params mem summary location let val_unknown = Dom.Val.unknown_from ~callee_pname ~location in
| None -> Models.model_by_value val_unknown ret mem |> Dom.Mem.add_heap Loc.unknown val_unknown
L.(debug BufferOverrun Verbose) )
"/!\\ Unknown call to %a at %a@\n" Typ.Procname.pp callee_pname Location.pp
location ;
let val_unknown = Dom.Val.unknown_from ~callee_pname ~location in
Models.model_by_value val_unknown model_env mem
|> Dom.Mem.add_heap Loc.unknown val_unknown )
| Declare_locals (locals, location) -> | Declare_locals (locals, location) ->
(* array allocation in stack e.g., int arr[10] *) (* array allocation in stack e.g., int arr[10] *)
let rec decl_local pname node location loc typ ~inst_num ~dimension mem = let rec decl_local pname node location loc typ ~inst_num ~dimension mem =

@ -167,7 +167,7 @@ module Make (BoUtils : BufferOverrunUtils.S) = struct
{exec; check} {exec; check}
let model_by_value value {ret} mem = let model_by_value value ret mem =
match ret with match ret with
| Some (id, _) -> | Some (id, _) ->
Dom.Mem.add_stack (Loc.of_id id) value mem Dom.Mem.add_stack (Loc.of_id id) value mem
@ -177,7 +177,10 @@ module Make (BoUtils : BufferOverrunUtils.S) = struct
mem mem
let by_value value = {exec= model_by_value value; check= no_check} let by_value value =
let exec {ret} mem = model_by_value value ret mem in
{exec; check= no_check}
let bottom = let bottom =
let exec _model_env _mem = Bottom in let exec _model_env _mem = Bottom in

Loading…
Cancel
Save