[refactor] Correct misnomer: params -> args

Summary: We have been referring to the arguments of a function call as "params". This has been bothering me. Let's fix it!

Reviewed By: ngorogiannis

Differential Revision: D27649158

fbshipit-source-id: 10e0b28cb
master
Ezgi Çiçek 4 years ago committed by Facebook GitHub Bot
parent fbcf418ea4
commit fb75c2fb11

@ -87,9 +87,9 @@ module ReplaceObjCCopy = struct
&& Option.exists class_name_opt ~f:(String.equal class_name) ) && Option.exists class_name_opt ~f:(String.equal class_name) )
let get_replaced_instr {protocol; method_name; method_with_zone; is_mutable} pdesc tenv params let get_replaced_instr {protocol; method_name; method_with_zone; is_mutable} pdesc tenv args
ret_id_typ loc flags = ret_id_typ loc flags =
match objc_get_first_arg_typ params with match objc_get_first_arg_typ args with
| Some cl -> | Some cl ->
let class_name = Typ.Name.name cl in let class_name = Typ.Name.name cl in
if if
@ -107,7 +107,7 @@ module ReplaceObjCCopy = struct
(Sil.Call (Sil.Call
( ret_id_typ ( ret_id_typ
, function_exp , function_exp
, params @ [(Exp.null, StdTyp.Objc.pointer_to_nszone)] , args @ [(Exp.null, StdTyp.Objc.pointer_to_nszone)]
, loc , loc
, flags )) ) , flags )) )
else None else None
@ -115,10 +115,10 @@ module ReplaceObjCCopy = struct
None None
let process tenv pdesc ret_id_typ callee params loc flags = let process tenv pdesc ret_id_typ callee args loc flags =
get_copy_kind_opt callee get_copy_kind_opt callee
|> Option.bind ~f:(fun copy_kind -> |> Option.bind ~f:(fun copy_kind ->
get_replaced_instr copy_kind pdesc tenv params ret_id_typ loc flags ) get_replaced_instr copy_kind pdesc tenv args ret_id_typ loc flags )
end end
module ReplaceObjCOverridden = struct module ReplaceObjCOverridden = struct
@ -126,10 +126,10 @@ module ReplaceObjCOverridden = struct
Option.exists class_name_opt ~f:(Typ.Name.equal object_name) Option.exists class_name_opt ~f:(Typ.Name.equal object_name)
let get_overridden_method_opt tenv ~caller_class_name ~callee params = let get_overridden_method_opt tenv ~caller_class_name ~callee args =
let open IOption.Let_syntax in let open IOption.Let_syntax in
let* sup_class_name = Procname.get_class_type_name callee in let* sup_class_name = Procname.get_class_type_name callee in
let* sub_class_name = objc_get_first_arg_typ params in let* sub_class_name = objc_get_first_arg_typ args in
if if
PatternMatch.is_subtype tenv sub_class_name sup_class_name PatternMatch.is_subtype tenv sub_class_name sup_class_name
&& not (may_be_super_call caller_class_name sub_class_name) && not (may_be_super_call caller_class_name sub_class_name)
@ -139,24 +139,24 @@ module ReplaceObjCOverridden = struct
else None else None
let process tenv caller ret_id_typ callee params loc flags = let process tenv caller ret_id_typ callee args loc flags =
get_overridden_method_opt tenv get_overridden_method_opt tenv
~caller_class_name:(Procname.get_class_type_name caller) ~caller_class_name:(Procname.get_class_type_name caller)
~callee params ~callee args
|> Option.map ~f:(fun overridden_method -> |> Option.map ~f:(fun overridden_method ->
Logging.d_printfln_escaped "Replace overridden method %a to %a" Procname.pp callee Logging.d_printfln_escaped "Replace overridden method %a to %a" Procname.pp callee
Procname.pp overridden_method ; Procname.pp overridden_method ;
Sil.Call (ret_id_typ, Const (Cfun overridden_method), params, loc, flags) ) Sil.Call (ret_id_typ, Const (Cfun overridden_method), args, loc, flags) )
end end
module ReplaceObjCMethodCall = struct module ReplaceObjCMethodCall = struct
let process tenv pdesc caller = let process tenv pdesc caller =
let replace_method instr = let replace_method instr =
match (instr : Sil.instr) with match (instr : Sil.instr) with
| Call (ret_id_typ, Const (Cfun callee), params, loc, flags) -> | Call (ret_id_typ, Const (Cfun callee), args, loc, flags) ->
IOption.if_none_evalopt IOption.if_none_evalopt
(ReplaceObjCCopy.process tenv pdesc ret_id_typ callee params loc flags) ~f:(fun () -> (ReplaceObjCCopy.process tenv pdesc ret_id_typ callee args loc flags) ~f:(fun () ->
ReplaceObjCOverridden.process tenv caller ret_id_typ callee params loc flags ) ReplaceObjCOverridden.process tenv caller ret_id_typ callee args loc flags )
|> Option.value ~default:instr |> Option.value ~default:instr
| _ -> | _ ->
instr instr

@ -120,7 +120,7 @@ module TransferFunctions = struct
let instantiate_mem : let instantiate_mem :
is_params_ref:bool is_args_ref:bool
-> Typ.IntegerWidths.t -> Typ.IntegerWidths.t
-> Ident.t -> Ident.t
-> (Pvar.t * Typ.t) list -> (Pvar.t * Typ.t) list
@ -130,10 +130,10 @@ module TransferFunctions = struct
-> BufferOverrunAnalysisSummary.t -> BufferOverrunAnalysisSummary.t
-> Location.t -> Location.t
-> Dom.Mem.t = -> Dom.Mem.t =
fun ~is_params_ref integer_type_widths ret_id callee_formals callee_pname params caller_mem fun ~is_args_ref integer_type_widths ret_id callee_formals callee_pname args caller_mem
callee_exit_mem location -> callee_exit_mem location ->
let eval_sym_trace = let eval_sym_trace =
Sem.mk_eval_sym_trace ~is_params_ref integer_type_widths callee_formals params caller_mem Sem.mk_eval_sym_trace ~is_args_ref integer_type_widths callee_formals args caller_mem
~mode:Sem.EvalNormal ~mode:Sem.EvalNormal
in in
let mem = let mem =
@ -279,10 +279,10 @@ module TransferFunctions = struct
let call {interproc= {tenv}; get_summary; get_formals; oenv= {integer_type_widths}} node location let call {interproc= {tenv}; get_summary; get_formals; oenv= {integer_type_widths}} node location
((id, _) as ret) callee_pname params mem = ((id, _) as ret) callee_pname args mem =
let mem = Dom.Mem.add_stack_loc (Loc.of_id id) mem in let mem = Dom.Mem.add_stack_loc (Loc.of_id id) mem in
let fun_arg_list = let fun_arg_list =
List.map params ~f:(fun (exp, typ) -> List.map args ~f:(fun (exp, typ) ->
ProcnameDispatcher.Call.FuncArg.{exp; typ; arg_payload= ()} ) ProcnameDispatcher.Call.FuncArg.{exp; typ; arg_payload= ()} )
in in
match Models.Call.dispatch tenv callee_pname fun_arg_list with match Models.Call.dispatch tenv callee_pname fun_arg_list with
@ -294,13 +294,13 @@ module TransferFunctions = struct
in in
exec model_env ~ret mem exec model_env ~ret mem
| None -> ( | None -> (
let {BoUtils.ReplaceCallee.pname= callee_pname; params; is_params_ref} = let {BoUtils.ReplaceCallee.pname= callee_pname; args; is_args_ref} =
BoUtils.ReplaceCallee.replace_make_shared tenv get_formals callee_pname params BoUtils.ReplaceCallee.replace_make_shared tenv get_formals callee_pname args
in in
match (get_summary callee_pname, get_formals callee_pname) with match (get_summary callee_pname, get_formals callee_pname) with
| Some callee_exit_mem, Some callee_formals -> | Some callee_exit_mem, Some callee_formals ->
instantiate_mem ~is_params_ref integer_type_widths id callee_formals callee_pname params instantiate_mem ~is_args_ref integer_type_widths id callee_formals callee_pname args mem
mem callee_exit_mem location callee_exit_mem location
| _, _ -> | _, _ ->
(* This may happen for procedures with a biabduction model too. *) (* This may happen for procedures with a biabduction model too. *)
L.d_printfln_escaped "/!\\ Unknown call to %a" Procname.pp callee_pname ; L.d_printfln_escaped "/!\\ Unknown call to %a" Procname.pp callee_pname ;
@ -410,13 +410,13 @@ module TransferFunctions = struct
assign_java_enum_values get_summary id assign_java_enum_values get_summary id
~caller_pname:(Procdesc.get_proc_name proc_desc) ~caller_pname:(Procdesc.get_proc_name proc_desc)
~callee_pname mem ~callee_pname mem
| Call (ret, Const (Cfun callee_pname), params, location, _) -> | Call (ret, Const (Cfun callee_pname), args, location, _) ->
call analysis_data node location ret callee_pname params mem call analysis_data node location ret callee_pname args mem
| Call (ret, fun_exp, params, location, _) -> ( | Call (ret, fun_exp, args, location, _) -> (
let func_ptrs = Sem.eval integer_type_widths fun_exp mem |> Dom.Val.get_func_ptrs in let func_ptrs = Sem.eval integer_type_widths fun_exp mem |> Dom.Val.get_func_ptrs in
match FuncPtr.Set.is_singleton_or_more func_ptrs with match FuncPtr.Set.is_singleton_or_more func_ptrs with
| Singleton (Closure {name= callee_pname}) -> | Singleton (Closure {name= callee_pname}) ->
call analysis_data node location ret callee_pname params mem call analysis_data node location ret callee_pname args mem
| More -> | More ->
L.d_printfln_escaped "/!\\ Call to multiple functions %a" Exp.pp fun_exp ; L.d_printfln_escaped "/!\\ Call to multiple functions %a" Exp.pp fun_exp ;
unknown_call location ret mem unknown_call location ret mem

@ -233,7 +233,7 @@ let rec check_expr_for_integer_overflow integer_type_widths pname exp location m
let instantiate_cond : let instantiate_cond :
is_params_ref:bool is_args_ref:bool
-> Typ.IntegerWidths.t -> Typ.IntegerWidths.t
-> Procname.t -> Procname.t
-> (Pvar.t * Typ.t) list -> (Pvar.t * Typ.t) list
@ -242,10 +242,10 @@ let instantiate_cond :
-> BufferOverrunCheckerSummary.t -> BufferOverrunCheckerSummary.t
-> Location.t -> Location.t
-> PO.ConditionSet.checked_t = -> PO.ConditionSet.checked_t =
fun ~is_params_ref integer_type_widths callee_pname callee_formals params caller_mem callee_cond fun ~is_args_ref integer_type_widths callee_pname callee_formals args caller_mem callee_cond
location -> location ->
let eval_sym_trace = let eval_sym_trace =
Sem.mk_eval_sym_trace ~is_params_ref integer_type_widths callee_formals params caller_mem Sem.mk_eval_sym_trace ~is_args_ref integer_type_widths callee_formals args caller_mem
in in
let latest_prune = Dom.Mem.get_latest_prune caller_mem in let latest_prune = Dom.Mem.get_latest_prune caller_mem in
PO.ConditionSet.subst callee_cond eval_sym_trace callee_pname location latest_prune PO.ConditionSet.subst callee_cond eval_sym_trace callee_pname location latest_prune
@ -280,13 +280,13 @@ let check_instr :
|> check_expr_for_array_access ~sub_expr_only:true integer_type_widths rexp location mem |> check_expr_for_array_access ~sub_expr_only:true integer_type_widths rexp location mem
|> check_expr_for_integer_overflow integer_type_widths pname lexp location mem |> check_expr_for_integer_overflow integer_type_widths pname lexp location mem
|> check_expr_for_integer_overflow integer_type_widths pname rexp location mem |> check_expr_for_integer_overflow integer_type_widths pname rexp location mem
| Sil.Call (_, Const (Cfun callee_pname), params, location, _) -> ( | Sil.Call (_, Const (Cfun callee_pname), args, location, _) -> (
let cond_set = let cond_set =
List.fold params ~init:cond_set ~f:(fun cond_set (exp, _) -> List.fold args ~init:cond_set ~f:(fun cond_set (exp, _) ->
check_expr_for_integer_overflow integer_type_widths pname exp location mem cond_set ) check_expr_for_integer_overflow integer_type_widths pname exp location mem cond_set )
in in
let fun_arg_list = let fun_arg_list =
List.map params ~f:(fun (exp, typ) -> List.map args ~f:(fun (exp, typ) ->
ProcnameDispatcher.Call.FuncArg.{exp; typ; arg_payload= ()} ) ProcnameDispatcher.Call.FuncArg.{exp; typ; arg_payload= ()} )
in in
match Models.Call.dispatch tenv callee_pname fun_arg_list with match Models.Call.dispatch tenv callee_pname fun_arg_list with
@ -298,13 +298,13 @@ let check_instr :
in in
check model_env mem cond_set check model_env mem cond_set
| None -> ( | None -> (
let {BoUtils.ReplaceCallee.pname= callee_pname; params; is_params_ref} = let {BoUtils.ReplaceCallee.pname= callee_pname; args; is_args_ref} =
BoUtils.ReplaceCallee.replace_make_shared tenv get_formals callee_pname params BoUtils.ReplaceCallee.replace_make_shared tenv get_formals callee_pname args
in in
match (get_checks_summary callee_pname, get_formals callee_pname) with match (get_checks_summary callee_pname, get_formals callee_pname) with
| Some callee_condset, Some callee_formals -> | Some callee_condset, Some callee_formals ->
instantiate_cond ~is_params_ref integer_type_widths callee_pname callee_formals params instantiate_cond ~is_args_ref integer_type_widths callee_pname callee_formals args mem
mem callee_condset location callee_condset location
|> PO.ConditionSet.join cond_set |> PO.ConditionSet.join cond_set
| _, _ -> | _, _ ->
(* unknown call / no inferbo payload *) cond_set ) ) (* unknown call / no inferbo payload *) cond_set ) )

@ -455,11 +455,11 @@ let eval_sympath ~mode params sympath mem =
(ArrayBlk.get_size ~cost_mode:(is_cost_mode mode) (Val.get_array_blk v), Val.get_traces v) (ArrayBlk.get_size ~cost_mode:(is_cost_mode mode) (Val.get_array_blk v), Val.get_traces v)
let mk_eval_sym_trace ?(is_params_ref = false) integer_type_widths let mk_eval_sym_trace ?(is_args_ref = false) integer_type_widths
(callee_formals : (Pvar.t * Typ.t) list) (actual_exps : (Exp.t * Typ.t) list) caller_mem = (callee_formals : (Pvar.t * Typ.t) list) (actual_exps : (Exp.t * Typ.t) list) caller_mem =
let params = let args =
let actuals = let actuals =
if is_params_ref then if is_args_ref then
match actual_exps with match actual_exps with
| [] -> | [] ->
[] []
@ -482,17 +482,17 @@ let mk_eval_sym_trace ?(is_params_ref = false) integer_type_widths
in in
let eval_sym ~mode s bound_end = let eval_sym ~mode s bound_end =
let sympath = Symb.Symbol.path s in let sympath = Symb.Symbol.path s in
let itv, _ = eval_sympath ~mode params sympath caller_mem in let itv, _ = eval_sympath ~mode args sympath caller_mem in
Symb.Symbol.check_bound_end s bound_end ; Symb.Symbol.check_bound_end s bound_end ;
Itv.get_bound itv bound_end Itv.get_bound itv bound_end
in in
let eval_locpath ~mode partial = eval_locpath ~mode params partial caller_mem in let eval_locpath ~mode partial = eval_locpath ~mode args partial caller_mem in
let eval_func_ptrs ~mode partial = let eval_func_ptrs ~mode partial =
eval_sympath_partial ~mode params partial caller_mem |> Val.get_func_ptrs eval_sympath_partial ~mode args partial caller_mem |> Val.get_func_ptrs
in in
let trace_of_sym s = let trace_of_sym s =
let sympath = Symb.Symbol.path s in let sympath = Symb.Symbol.path s in
let itv, traces = eval_sympath ~mode:EvalNormal params sympath caller_mem in let itv, traces = eval_sympath ~mode:EvalNormal args sympath caller_mem in
if Itv.eq itv Itv.bot then TraceSet.bottom else traces if Itv.eq itv Itv.bot then TraceSet.bottom else traces
in in
fun ~mode -> fun ~mode ->

@ -65,7 +65,7 @@ type eval_mode =
the cost values only care about the upperbounds. *) the cost values only care about the upperbounds. *)
val mk_eval_sym_trace : val mk_eval_sym_trace :
?is_params_ref:bool ?is_args_ref:bool
-> Typ.IntegerWidths.t -> Typ.IntegerWidths.t
-> (Pvar.t * Typ.t) list -> (Pvar.t * Typ.t) list
-> (Exp.t * Typ.t) list -> (Exp.t * Typ.t) list

@ -339,7 +339,7 @@ end
type get_formals = Procname.t -> (Pvar.t * Typ.t) list option type get_formals = Procname.t -> (Pvar.t * Typ.t) list option
module ReplaceCallee = struct module ReplaceCallee = struct
type replaced = {pname: Procname.t; params: (Exp.t * Typ.t) list; is_params_ref: bool} type replaced = {pname: Procname.t; args: (Exp.t * Typ.t) list; is_args_ref: bool}
let is_cpp_constructor_with_types get_formals class_typ param_ref_typs pname = let is_cpp_constructor_with_types get_formals class_typ param_ref_typs pname =
let num_params = List.length param_ref_typs in let num_params = List.length param_ref_typs in
@ -408,16 +408,16 @@ module ReplaceCallee = struct
result ) result )
let replace_make_shared tenv get_formals pname params = let replace_make_shared tenv get_formals pname args =
match get_cpp_constructor_of_make_shared tenv get_formals pname with match get_cpp_constructor_of_make_shared tenv get_formals pname with
| Some constr -> | Some constr ->
(* NOTE: This replaces the pointer to the target object. In the parameters of (* NOTE: This replaces the pointer to the target object. In the parameters of
[std::make_shared], the pointer is on the last place. On the other hand, it is on the [std::make_shared], the pointer is on the last place. On the other hand, it is on the
first place in the constructor's parameters. *) first place in the constructor's parameters. *)
let params = IList.move_last_to_first params in let args = IList.move_last_to_first args in
{pname= constr; params; is_params_ref= true} {pname= constr; args; is_args_ref= true}
| None -> | None ->
{pname; params; is_params_ref= false} {pname; args; is_args_ref= false}
end end
let clear_cache () = ReplaceCallee.CacheForMakeShared.clear () let clear_cache () = ReplaceCallee.CacheForMakeShared.clear ()

@ -106,16 +106,16 @@ type get_formals = Procname.t -> (Pvar.t * Typ.t) list option
module ReplaceCallee : sig module ReplaceCallee : sig
(** Replaced proc name with its modified parameters. (** Replaced proc name with its modified parameters.
[is_params_ref] represents that the parameters are given as references to variables, e.g., [is_args_ref] represents that the arguments are given as references to variables, e.g., when
when [int i = 5;], the function of [std::make_shared<C>(i);] in C++ is translated to [int i = 5;], the function of [std::make_shared<C>(i);] in C++ is translated to
[std::make_shared<C>(&i, tgt)] in Sil where [tgt] is the variable for the target object, [std::make_shared<C>(&i, tgt)] in Sil where [tgt] is the variable for the target object,
rather than [std::make_shared<C>(i, tgt)] (note that the type of [&i] is [int&]). rather than [std::make_shared<C>(i, tgt)] (note that the type of [&i] is [int&]).
The [is_params_ref] value is used to evaluate parameters correctly after replacing the callee. The [is_args_ref] value is used to evaluate argments correctly after replacing the callee. For
For example, when we replace [std::make_shared<C>(&i, tgt)] to the constructor call of [C], example, when we replace [std::make_shared<C>(&i, tgt)] to the constructor call of [C], i.e.
i.e. [C(tgt, i)], the parameters' order and types are slightly different, so which should be [C(tgt, i)], the arguments' order and types are slightly different, so which should be handled
handled correctly later in the instantiation phase. *) correctly later in the instantiation phase. *)
type replaced = {pname: Procname.t; params: (Exp.t * Typ.t) list; is_params_ref: bool} type replaced = {pname: Procname.t; args: (Exp.t * Typ.t) list; is_args_ref: bool}
val replace_make_shared : Tenv.t -> get_formals -> Procname.t -> (Exp.t * Typ.t) list -> replaced val replace_make_shared : Tenv.t -> get_formals -> Procname.t -> (Exp.t * Typ.t) list -> replaced
end end

@ -3756,10 +3756,10 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
let res_trans_subexpr_list = let res_trans_subexpr_list =
List.map ~f:(exec_with_glvalue_as_reference instruction trans_state_param) stmts List.map ~f:(exec_with_glvalue_as_reference instruction trans_state_param) stmts
in in
let params = collect_returns res_trans_subexpr_list in let args = collect_returns res_trans_subexpr_list in
let sil_fun = Exp.Const (Const.Cfun pname) in let sil_fun = Exp.Const (Const.Cfun pname) in
let ret_id = Ident.create_fresh Ident.knormal in let ret_id = Ident.create_fresh Ident.knormal in
let call_instr = Sil.Call ((ret_id, ret_typ), sil_fun, params, sil_loc, CallFlags.default) in let call_instr = Sil.Call ((ret_id, ret_typ), sil_fun, args, sil_loc, CallFlags.default) in
let res_trans_call = let res_trans_call =
mk_trans_result (Exp.Var ret_id, ret_typ) {empty_control with instrs= [call_instr]} mk_trans_result (Exp.Var ret_id, ret_typ) {empty_control with instrs= [call_instr]}
in in
@ -3862,12 +3862,12 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
let trans_state_pri = PriorityNode.try_claim_priority_node trans_state stmt_info in let trans_state_pri = PriorityNode.try_claim_priority_node trans_state stmt_info in
let trans_state_param = {trans_state_pri with succ_nodes= []; var_exp_typ= None} in let trans_state_param = {trans_state_pri with succ_nodes= []; var_exp_typ= None} in
let res_trans_subexpr_list = List.map ~f:(instruction trans_state_param) stmts in let res_trans_subexpr_list = List.map ~f:(instruction trans_state_param) stmts in
let params = collect_returns res_trans_subexpr_list in let args = collect_returns res_trans_subexpr_list in
let ret_id = Ident.create_fresh Ident.knormal in let ret_id = Ident.create_fresh Ident.knormal in
let ret_exp = Exp.Var ret_id in let ret_exp = Exp.Var ret_id in
let res_instr = let res_instr =
let sil_fun = Exp.Const (Const.Cfun BuiltinDecl.__infer_initializer_list) in let sil_fun = Exp.Const (Const.Cfun BuiltinDecl.__infer_initializer_list) in
Sil.Call ((ret_id, typ), sil_fun, params, sil_loc, CallFlags.default) Sil.Call ((ret_id, typ), sil_fun, args, sil_loc, CallFlags.default)
in in
let res_trans_call = mk_trans_result (ret_exp, typ) {empty_control with instrs= [res_instr]} in let res_trans_call = mk_trans_result (ret_exp, typ) {empty_control with instrs= [res_instr]} in
let all_res_trans = res_trans_subexpr_list @ [res_trans_call] in let all_res_trans = res_trans_subexpr_list @ [res_trans_call] in

@ -27,9 +27,9 @@ type extras_WorstCaseCost =
; proc_resolve_attributes: Procname.t -> ProcAttributes.t option } ; proc_resolve_attributes: Procname.t -> ProcAttributes.t option }
let instantiate_cost ?get_closure_callee_cost ~default_closure_cost integer_type_widths let instantiate_cost ?get_closure_callee_cost ~default_closure_cost integer_type_widths
~inferbo_caller_mem ~callee_pname ~callee_formals ~params ~callee_cost ~loc = ~inferbo_caller_mem ~callee_pname ~callee_formals ~args ~callee_cost ~loc =
let {BufferOverrunDomain.eval_sym; eval_func_ptrs} = let {BufferOverrunDomain.eval_sym; eval_func_ptrs} =
BufferOverrunSemantics.mk_eval_sym_cost integer_type_widths callee_formals params BufferOverrunSemantics.mk_eval_sym_cost integer_type_widths callee_formals args
inferbo_caller_mem inferbo_caller_mem
in in
let get_closure_callee_cost pname = let get_closure_callee_cost pname =
@ -143,7 +143,7 @@ module InstrBasicCostWithReason = struct
let get_instr_cost_record tenv extras cfg instr_node instr = let get_instr_cost_record tenv extras cfg instr_node instr =
match instr with match instr with
| Sil.Call (ret, Exp.Const (Const.Cfun callee_pname), params, location, _) | Sil.Call (ret, Exp.Const (Const.Cfun callee_pname), args, location, _)
when Config.inclusive_cost -> ( when Config.inclusive_cost -> (
let { inferbo_invariant_map let { inferbo_invariant_map
; integer_type_widths ; integer_type_widths
@ -153,7 +153,7 @@ module InstrBasicCostWithReason = struct
extras extras
in in
let fun_arg_list = let fun_arg_list =
List.map params ~f:(fun (exp, typ) -> List.map args ~f:(fun (exp, typ) ->
ProcnameDispatcher.Call.FuncArg.{exp; typ; arg_payload= ()} ) ProcnameDispatcher.Call.FuncArg.{exp; typ; arg_payload= ()} )
in in
let inferbo_mem_opt = let inferbo_mem_opt =
@ -184,7 +184,7 @@ module InstrBasicCostWithReason = struct
in in
instantiate_cost ~get_closure_callee_cost ~default_closure_cost instantiate_cost ~get_closure_callee_cost ~default_closure_cost
integer_type_widths ~inferbo_caller_mem:inferbo_mem ~callee_pname integer_type_widths ~inferbo_caller_mem:inferbo_mem ~callee_pname
~callee_formals ~params ~callee_cost ~loc:location ) ~callee_formals ~args ~callee_cost ~loc:location )
| _ -> | _ ->
None None
in in

@ -21,7 +21,7 @@ val instantiate_cost :
-> inferbo_caller_mem:BufferOverrunDomain.Mem.t -> inferbo_caller_mem:BufferOverrunDomain.Mem.t
-> callee_pname:Procname.t -> callee_pname:Procname.t
-> callee_formals:(Pvar.t * Typ.t) list -> callee_formals:(Pvar.t * Typ.t) list
-> params:(Exp.t * Typ.t) list -> args:(Exp.t * Typ.t) list
-> callee_cost:CostDomain.BasicCostWithReason.t -> callee_cost:CostDomain.BasicCostWithReason.t
-> loc:Location.t -> loc:Location.t
-> CostDomain.BasicCostWithReason.t -> CostDomain.BasicCostWithReason.t

@ -14,7 +14,7 @@ module Call = struct
{ loc: Location.t { loc: Location.t
; pname: Procname.t ; pname: Procname.t
; node: Procdesc.Node.t ; node: Procdesc.Node.t
; params: (Exp.t * Typ.t) list ; args: (Exp.t * Typ.t) list
; ret: Ident.t * Typ.t } ; ret: Ident.t * Typ.t }
[@@deriving compare] [@@deriving compare]
@ -35,12 +35,12 @@ module LoopHeadToHoistInstrs = Procdesc.NodeMap
let add_if_hoistable inv_vars instr node source_nodes idom hoistable_calls = let add_if_hoistable inv_vars instr node source_nodes idom hoistable_calls =
match instr with match instr with
| Sil.Call (((ret_id, _) as ret), Exp.Const (Const.Cfun pname), params, loc, _) | Sil.Call (((ret_id, _) as ret), Exp.Const (Const.Cfun pname), args, loc, _)
when (* Check condition (1); N dominates all loop sources *) when (* Check condition (1); N dominates all loop sources *)
List.for_all ~f:(fun source -> Dominators.dominates idom node source) source_nodes List.for_all ~f:(fun source -> Dominators.dominates idom node source) source_nodes
&& (* Check condition (2); id should be invariant already *) && (* Check condition (2); id should be invariant already *)
LoopInvariant.InvariantVars.mem (Var.of_id ret_id) inv_vars -> LoopInvariant.InvariantVars.mem (Var.of_id ret_id) inv_vars ->
HoistCalls.add {pname; loc; node; params; ret} hoistable_calls HoistCalls.add {pname; loc; node; args; ret} hoistable_calls
| _ -> | _ ->
hoistable_calls hoistable_calls
@ -100,7 +100,7 @@ let do_report extract_cost_if_expensive proc_desc err_log (Call.{pname; loc} as
let get_cost_if_expensive tenv integer_type_widths get_callee_cost_summary_and_formals let get_cost_if_expensive tenv integer_type_widths get_callee_cost_summary_and_formals
inferbo_invariant_map inferbo_get_summary Call.{pname; node; ret; params} = inferbo_invariant_map inferbo_get_summary Call.{pname; node; ret; args} =
let last_node = InstrCFG.last_of_underlying_node node in let last_node = InstrCFG.last_of_underlying_node node in
let inferbo_mem = let inferbo_mem =
let instr_node_id = InstrCFG.Node.id last_node in let instr_node_id = InstrCFG.Node.id last_node in
@ -115,13 +115,13 @@ let get_cost_if_expensive tenv integer_type_widths get_callee_cost_summary_and_f
if CostDomain.BasicCost.is_symbolic callee_cost.cost then if CostDomain.BasicCost.is_symbolic callee_cost.cost then
Some Some
(Cost.instantiate_cost ~default_closure_cost:Ints.NonNegativeInt.one integer_type_widths (Cost.instantiate_cost ~default_closure_cost:Ints.NonNegativeInt.one integer_type_widths
~inferbo_caller_mem:inferbo_mem ~callee_pname:pname ~callee_formals ~params ~inferbo_caller_mem:inferbo_mem ~callee_pname:pname ~callee_formals ~args
~callee_cost ~loc) ~callee_cost ~loc)
.cost .cost
else None else None
| None -> | None ->
let fun_arg_list = let fun_arg_list =
List.map params ~f:(fun (exp, typ) -> List.map args ~f:(fun (exp, typ) ->
ProcnameDispatcher.Call.FuncArg.{exp; typ; arg_payload= ()} ) ProcnameDispatcher.Call.FuncArg.{exp; typ; arg_payload= ()} )
in in
CostModels.Call.dispatch tenv pname fun_arg_list CostModels.Call.dispatch tenv pname fun_arg_list

Loading…
Cancel
Save