[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) )
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 =
match objc_get_first_arg_typ params with
match objc_get_first_arg_typ args with
| Some cl ->
let class_name = Typ.Name.name cl in
if
@ -107,7 +107,7 @@ module ReplaceObjCCopy = struct
(Sil.Call
( ret_id_typ
, function_exp
, params @ [(Exp.null, StdTyp.Objc.pointer_to_nszone)]
, args @ [(Exp.null, StdTyp.Objc.pointer_to_nszone)]
, loc
, flags )) )
else None
@ -115,10 +115,10 @@ module ReplaceObjCCopy = struct
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
|> 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
module ReplaceObjCOverridden = struct
@ -126,10 +126,10 @@ module ReplaceObjCOverridden = struct
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* 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
PatternMatch.is_subtype tenv sub_class_name sup_class_name
&& not (may_be_super_call caller_class_name sub_class_name)
@ -139,24 +139,24 @@ module ReplaceObjCOverridden = struct
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
~caller_class_name:(Procname.get_class_type_name caller)
~callee params
~callee args
|> Option.map ~f:(fun overridden_method ->
Logging.d_printfln_escaped "Replace overridden method %a to %a" Procname.pp callee
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
module ReplaceObjCMethodCall = struct
let process tenv pdesc caller =
let replace_method instr =
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
(ReplaceObjCCopy.process tenv pdesc ret_id_typ callee params loc flags) ~f:(fun () ->
ReplaceObjCOverridden.process tenv caller ret_id_typ callee params loc flags )
(ReplaceObjCCopy.process tenv pdesc ret_id_typ callee args loc flags) ~f:(fun () ->
ReplaceObjCOverridden.process tenv caller ret_id_typ callee args loc flags )
|> Option.value ~default:instr
| _ ->
instr

@ -120,7 +120,7 @@ module TransferFunctions = struct
let instantiate_mem :
is_params_ref:bool
is_args_ref:bool
-> Typ.IntegerWidths.t
-> Ident.t
-> (Pvar.t * Typ.t) list
@ -130,10 +130,10 @@ module TransferFunctions = struct
-> BufferOverrunAnalysisSummary.t
-> Location.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 ->
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
in
let mem =
@ -279,10 +279,10 @@ module TransferFunctions = struct
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 fun_arg_list =
List.map params ~f:(fun (exp, typ) ->
List.map args ~f:(fun (exp, typ) ->
ProcnameDispatcher.Call.FuncArg.{exp; typ; arg_payload= ()} )
in
match Models.Call.dispatch tenv callee_pname fun_arg_list with
@ -294,13 +294,13 @@ module TransferFunctions = struct
in
exec model_env ~ret mem
| None -> (
let {BoUtils.ReplaceCallee.pname= callee_pname; params; is_params_ref} =
BoUtils.ReplaceCallee.replace_make_shared tenv get_formals callee_pname params
let {BoUtils.ReplaceCallee.pname= callee_pname; args; is_args_ref} =
BoUtils.ReplaceCallee.replace_make_shared tenv get_formals callee_pname args
in
match (get_summary callee_pname, get_formals callee_pname) with
| Some callee_exit_mem, Some callee_formals ->
instantiate_mem ~is_params_ref integer_type_widths id callee_formals callee_pname params
mem callee_exit_mem location
instantiate_mem ~is_args_ref integer_type_widths id callee_formals callee_pname args mem
callee_exit_mem location
| _, _ ->
(* This may happen for procedures with a biabduction model too. *)
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
~caller_pname:(Procdesc.get_proc_name proc_desc)
~callee_pname mem
| Call (ret, Const (Cfun callee_pname), params, location, _) ->
call analysis_data node location ret callee_pname params mem
| Call (ret, fun_exp, params, location, _) -> (
| Call (ret, Const (Cfun callee_pname), args, location, _) ->
call analysis_data node location ret callee_pname args mem
| Call (ret, fun_exp, args, location, _) -> (
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
| 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 ->
L.d_printfln_escaped "/!\\ Call to multiple functions %a" Exp.pp fun_exp ;
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 :
is_params_ref:bool
is_args_ref:bool
-> Typ.IntegerWidths.t
-> Procname.t
-> (Pvar.t * Typ.t) list
@ -242,10 +242,10 @@ let instantiate_cond :
-> BufferOverrunCheckerSummary.t
-> Location.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 ->
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
let latest_prune = Dom.Mem.get_latest_prune caller_mem in
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_integer_overflow integer_type_widths pname lexp 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 =
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 )
in
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= ()} )
in
match Models.Call.dispatch tenv callee_pname fun_arg_list with
@ -298,13 +298,13 @@ let check_instr :
in
check model_env mem cond_set
| None -> (
let {BoUtils.ReplaceCallee.pname= callee_pname; params; is_params_ref} =
BoUtils.ReplaceCallee.replace_make_shared tenv get_formals callee_pname params
let {BoUtils.ReplaceCallee.pname= callee_pname; args; is_args_ref} =
BoUtils.ReplaceCallee.replace_make_shared tenv get_formals callee_pname args
in
match (get_checks_summary callee_pname, get_formals callee_pname) with
| Some callee_condset, Some callee_formals ->
instantiate_cond ~is_params_ref integer_type_widths callee_pname callee_formals params
mem callee_condset location
instantiate_cond ~is_args_ref integer_type_widths callee_pname callee_formals args mem
callee_condset location
|> PO.ConditionSet.join 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)
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 =
let params =
let args =
let actuals =
if is_params_ref then
if is_args_ref then
match actual_exps with
| [] ->
[]
@ -482,17 +482,17 @@ let mk_eval_sym_trace ?(is_params_ref = false) integer_type_widths
in
let eval_sym ~mode s bound_end =
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 ;
Itv.get_bound itv bound_end
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 =
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
let trace_of_sym s =
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
in
fun ~mode ->

@ -65,7 +65,7 @@ type eval_mode =
the cost values only care about the upperbounds. *)
val mk_eval_sym_trace :
?is_params_ref:bool
?is_args_ref:bool
-> Typ.IntegerWidths.t
-> (Pvar.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
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 num_params = List.length param_ref_typs in
@ -408,16 +408,16 @@ module ReplaceCallee = struct
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
| Some constr ->
(* 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
first place in the constructor's parameters. *)
let params = IList.move_last_to_first params in
{pname= constr; params; is_params_ref= true}
let args = IList.move_last_to_first args in
{pname= constr; args; is_args_ref= true}
| None ->
{pname; params; is_params_ref= false}
{pname; args; is_args_ref= false}
end
let clear_cache () = ReplaceCallee.CacheForMakeShared.clear ()

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

@ -3756,10 +3756,10 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
let res_trans_subexpr_list =
List.map ~f:(exec_with_glvalue_as_reference 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 sil_fun = Exp.Const (Const.Cfun pname) 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 =
mk_trans_result (Exp.Var ret_id, ret_typ) {empty_control with instrs= [call_instr]}
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_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 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_exp = Exp.Var ret_id in
let res_instr =
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
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

@ -27,9 +27,9 @@ type extras_WorstCaseCost =
; proc_resolve_attributes: Procname.t -> ProcAttributes.t option }
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} =
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
in
let get_closure_callee_cost pname =
@ -143,7 +143,7 @@ module InstrBasicCostWithReason = struct
let get_instr_cost_record tenv extras cfg instr_node instr =
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 -> (
let { inferbo_invariant_map
; integer_type_widths
@ -153,7 +153,7 @@ module InstrBasicCostWithReason = struct
extras
in
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= ()} )
in
let inferbo_mem_opt =
@ -184,7 +184,7 @@ module InstrBasicCostWithReason = struct
in
instantiate_cost ~get_closure_callee_cost ~default_closure_cost
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
in

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

@ -14,7 +14,7 @@ module Call = struct
{ loc: Location.t
; pname: Procname.t
; node: Procdesc.Node.t
; params: (Exp.t * Typ.t) list
; args: (Exp.t * Typ.t) list
; ret: Ident.t * Typ.t }
[@@deriving compare]
@ -35,12 +35,12 @@ module LoopHeadToHoistInstrs = Procdesc.NodeMap
let add_if_hoistable inv_vars instr node source_nodes idom hoistable_calls =
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 *)
List.for_all ~f:(fun source -> Dominators.dominates idom node source) source_nodes
&& (* Check condition (2); id should be invariant already *)
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
@ -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
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 inferbo_mem =
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
Some
(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)
.cost
else None
| None ->
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= ()} )
in
CostModels.Call.dispatch tenv pname fun_arg_list

Loading…
Cancel
Save