[inferbo] Use record type for eval_sym_trace

Reviewed By: mbouaziz

Differential Revision: D13231245

fbshipit-source-id: 797f6d795
master
Sungkeun Cho 6 years ago committed by Facebook Github Bot
parent 33eabe6bfd
commit f70d6da8f2

@ -160,6 +160,9 @@ module PowLoc = struct
Boolean.EqualOrder.of_equal cmp_loc (Loc.eq loc1 loc2)
| _ ->
Boolean.Top
type eval_locpath = Symb.SymbolPath.partial -> t
end
(** unsound but ok for bug catching *)

@ -34,8 +34,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
type nonrec extras = extras
let instantiate_ret (id, _) callee_pname ~callee_exit_mem eval_sym_trace
eval_locs_sympath_partial mem location =
let instantiate_ret (id, _) callee_pname ~callee_exit_mem eval_sym_trace mem location =
let copy_reachable_new_locs_from locs mem =
let copy loc acc =
Option.value_map (Dom.Mem.find_opt loc callee_exit_mem) ~default:acc ~f:(fun v ->
@ -49,7 +48,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
let subst_loc l =
Option.find_map (Loc.get_path l) ~f:(fun partial ->
try
let locs = eval_locs_sympath_partial partial in
let locs = eval_sym_trace.Dom.eval_locpath partial in
match PowLoc.is_singleton_or_more locs with
| IContainer.Singleton loc ->
Some loc
@ -134,12 +133,11 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
let rel_subst_map =
Sem.get_subst_map tenv integer_type_widths callee_pdesc params caller_mem callee_exit_mem
in
let eval_sym_trace, eval_locpath =
let eval_sym_trace =
Sem.mk_eval_sym_trace integer_type_widths callee_pdesc params caller_mem
in
let caller_mem =
instantiate_ret ret callee_pname ~callee_exit_mem eval_sym_trace eval_locpath caller_mem
location
instantiate_ret ret callee_pname ~callee_exit_mem eval_sym_trace caller_mem location
|> instantiate_param tenv integer_type_widths callee_pdesc params callee_exit_mem
eval_sym_trace location
|> forget_ret_relation ret callee_pname
@ -598,7 +596,7 @@ module Report = struct
in
let pname = Procdesc.get_proc_name callee_pdesc in
let caller_rel = Dom.Mem.get_relation caller_mem in
let eval_sym_trace, _ =
let eval_sym_trace =
Sem.mk_eval_sym_trace integer_type_widths callee_pdesc params caller_mem
in
PO.ConditionSet.subst callee_cond eval_sym_trace rel_subst_map caller_rel pname location

@ -16,6 +16,11 @@ module Relation = BufferOverrunDomainRelation
module Trace = BufferOverrunTrace
module TraceSet = Trace.Set
type eval_sym_trace =
{ eval_sym: Bounds.Bound.eval_sym
; trace_of_sym: Symb.Symbol.t -> Trace.Set.t
; eval_locpath: PowLoc.eval_locpath }
module Val = struct
type t =
{ itv: Itv.t
@ -311,8 +316,8 @@ module Val = struct
fun x -> {x with itv= Itv.normalize x.itv; arrayblk= ArrayBlk.normalize x.arrayblk}
let subst : t -> Bounds.Bound.eval_sym * (Symb.Symbol.t -> TraceSet.t) -> Location.t -> t =
fun x (eval_sym, trace_of_sym) location ->
let subst : t -> eval_sym_trace -> Location.t -> t =
fun x {eval_sym; trace_of_sym} location ->
let symbols = get_symbols x in
let traces_caller =
Itv.SymbolSet.fold

@ -10,6 +10,7 @@ open! AbstractDomain.Types
module F = Format
module L = Logging
module Bound = Bounds.Bound
module Dom = BufferOverrunDomain
module ItvPure = Itv.ItvPure
module MF = MarkupFormatter
module Relation = BufferOverrunDomainRelation
@ -694,7 +695,7 @@ module ConditionWithTrace = struct
cmp
let subst (eval_sym, trace_of_sym) rel_map caller_relation callee_pname call_site cwt =
let subst {Dom.eval_sym; trace_of_sym} rel_map caller_relation callee_pname call_site cwt =
let symbols = Condition.get_symbols cwt.cond in
if Symb.SymbolSet.is_empty symbols then
L.(die InternalError)

@ -67,7 +67,7 @@ module ConditionSet : sig
val subst :
summary_t
-> Bounds.Bound.eval_sym * (Symb.Symbol.t -> BufferOverrunTrace.Set.t)
-> BufferOverrunDomain.eval_sym_trace
-> Relation.SubstMap.t
-> Relation.t
-> Typ.Procname.t

@ -375,11 +375,12 @@ let mk_eval_sym_trace integer_type_widths callee_pdesc actual_exps caller_mem =
if Itv.eq itv Itv.bot then TraceSet.empty else traces
in
let eval_locpath partial = eval_locpath params partial caller_mem in
((eval_sym, trace_of_sym), eval_locpath)
{eval_sym; trace_of_sym; eval_locpath}
let mk_eval_sym integer_type_widths callee_pdesc actual_exps caller_mem =
fst (fst (mk_eval_sym_trace integer_type_widths callee_pdesc actual_exps caller_mem))
let eval_sym_trace = mk_eval_sym_trace integer_type_widths callee_pdesc actual_exps caller_mem in
eval_sym_trace.eval_sym
let get_sym_f integer_type_widths mem e = Val.get_sym (eval integer_type_widths e mem)

Loading…
Cancel
Save