let record_for_individual_froms (call_stack, instrstates) =
let instrstates = Lazy.force instrstates in
if From_parameters.ForceCallDeps.get () then begin
let module Froms_To_Use =
struct
let get _f callsite =
let _current_function, table = List.hd !call_froms_stack in
begin try
Kinstr.Hashtbl.find table callsite
with Not_found ->
raise Call_did_not_take_place
end
end
in
let module Values_To_Use =
struct
let get_stmt_state s =
try Stmt.Hashtbl.find instrstates s
with Not_found -> Cvalue.Model.bottom
let lval_to_loc_with_deps kinstr ~with_alarms:_ ~deps lv =
let state = get_stmt_state kinstr in
!Db.Value.lval_to_loc_with_deps_state state
~deps lv
let lval_to_loc_with_deps = ref lval_to_loc_with_deps
let expr_to_kernel_function kinstr ~with_alarms:_ ~deps exp =
let state = get_stmt_state kinstr in
!Db.Value.expr_to_kernel_function_state state ~deps exp
let expr_to_kernel_function = ref expr_to_kernel_function
let access_expr kinstr expr =
let state = get_stmt_state kinstr in
!Db.Value.eval_expr ~with_alarms:CilE.warn_none_mode state expr
let access_expr = ref access_expr
end
in
let module Recording_To_Do =
struct
let accept_base_in_lmap kf base =
let fundec = Kernel_function.get_definition kf in
not (Base.is_formal_or_local base fundec)
let final_cleanup _kf froms = froms
let record_kf _kf _last_froms = ()
end
in
let module Callwise_Froms =
Make(Values_To_Use)(Froms_To_Use)(Recording_To_Do)
in
let current_function, call_site = List.hd call_stack in
let froms = Callwise_Froms.compute_and_return current_function in
record_callwise_dependencies_in_db call_site froms;
match !call_froms_stack with
(current_function2, _) :: (((_caller, table) :: _) as tail) ->
assert (
if current_function2 != current_function then begin
From_parameters.fatal "calldeps %a != %a@."
Kernel_function.pretty current_function
Kernel_function.pretty current_function2;
end else
true);
call_froms_stack := tail;
merge_call_froms table call_site froms
| _ ->
Callwise_Dependencies.mark_as_computed ()
end