[eradicate] fix conflict between null assertions methods with a var args and the modeled methods using string formatter

Reviewed By: mbouaziz

Differential Revision: D13633856

fbshipit-source-id: caae3631b
master
Jeremy Dubreil 6 years ago committed by Facebook Github Bot
parent 6d562fc7b0
commit dc290555f1

@ -64,9 +64,7 @@ let is_check_not_null proc_name =
(** Parameter number for a procedure known to be a checkNotNull *) (** Parameter number for a procedure known to be a checkNotNull *)
let get_check_not_null_parameter proc_name = let get_check_not_null_parameter proc_name =
let proc_id = Typ.Procname.to_unique_id proc_name in let proc_id = Typ.Procname.to_unique_id proc_name in
try Hashtbl.find check_not_null_parameter_table proc_id with Caml.Not_found -> Hashtbl.find_opt check_not_null_parameter_table proc_id
(* Assume the check is on the first parameter unless modeled otherwise *)
1
(** Check if the procedure is one of the known Preconditions.checkState. *) (** Check if the procedure is one of the known Preconditions.checkState. *)

@ -800,13 +800,15 @@ let typecheck_instr tenv calls_this checks (node : Procdesc.Node.t) idenv curr_p
EradicateChecks.check_call_parameters tenv find_canonical_duplicate curr_pdesc node EradicateChecks.check_call_parameters tenv find_canonical_duplicate curr_pdesc node
callee_attributes resolved_params loc instr_ref ; callee_attributes resolved_params loc instr_ref ;
if Models.is_check_not_null callee_pname then if Models.is_check_not_null callee_pname then
if Typ.Procname.Java.is_vararg callee_pname_java then match Models.get_check_not_null_parameter callee_pname with
| Some index ->
do_preconditions_check_not_null index ~is_vararg:false typestate1
| None when Typ.Procname.Java.is_vararg callee_pname_java ->
let last_parameter = List.length call_params in let last_parameter = List.length call_params in
do_preconditions_check_not_null last_parameter ~is_vararg:true typestate1 do_preconditions_check_not_null last_parameter ~is_vararg:true typestate1
else | None ->
do_preconditions_check_not_null (* assume the first parameter is checked for null *)
(Models.get_check_not_null_parameter callee_pname) do_preconditions_check_not_null 1 ~is_vararg:false typestate1
~is_vararg:false typestate1
else if Models.is_check_state callee_pname || Models.is_check_argument callee_pname else if Models.is_check_state callee_pname || Models.is_check_argument callee_pname
then do_preconditions_check_state typestate1 then do_preconditions_check_state typestate1
else if Models.is_mapPut callee_pname then do_map_put typestate1 else if Models.is_mapPut callee_pname then do_map_put typestate1

Loading…
Cancel
Save