diff --git a/infer/src/backend/NoReturnModels.ml b/infer/src/absint/NoReturnModels.ml similarity index 100% rename from infer/src/backend/NoReturnModels.ml rename to infer/src/absint/NoReturnModels.ml diff --git a/infer/src/absint/PatternMatch.ml b/infer/src/absint/PatternMatch.ml index 155fa7cfc..52cc60006 100644 --- a/infer/src/absint/PatternMatch.ml +++ b/infer/src/absint/PatternMatch.ml @@ -300,26 +300,6 @@ let method_is_initializer (tenv : Tenv.t) (proc_attributes : ProcAttributes.t) : false -(** Get the vararg values by looking for array assignments to the pvar. *) -let java_get_vararg_values node pvar idenv = - let values_of_instr acc = function - | Sil.Store {e1= Exp.Lindex (array_exp, _); e2= content_exp} - when Exp.equal (Exp.Lvar pvar) (Idenv.expand_expr idenv array_exp) -> - (* Each vararg argument is an assignment to a pvar denoting an array of objects. *) - content_exp :: acc - | _ -> - acc - in - let values_of_node acc n = - Procdesc.Node.get_instrs n |> Instrs.fold ~f:values_of_instr ~init:acc - in - match Errdesc.find_program_variable_assignment node pvar with - | Some (node', _) -> - Procdesc.fold_slope_range node' node ~f:values_of_node ~init:[] - | None -> - [] - - let proc_calls resolve_attributes pdesc filter : (Procname.t * ProcAttributes.t) list = let res = ref [] in let do_instruction _ instr = diff --git a/infer/src/absint/PatternMatch.mli b/infer/src/absint/PatternMatch.mli index d918970e5..5ac56189c 100644 --- a/infer/src/absint/PatternMatch.mli +++ b/infer/src/absint/PatternMatch.mli @@ -104,9 +104,6 @@ val supertype_find_map_opt : Tenv.t -> (Typ.Name.t -> 'a option) -> Typ.Name.t - (** Return the first non-None result found when applying the given function to supertypes of the named type, including the type itself *) -val java_get_vararg_values : Procdesc.Node.t -> Pvar.t -> Idenv.t -> Exp.t list -(** Get the values of a vararg parameter given the pvar used to assign the elements. *) - val proc_calls : (Procname.t -> ProcAttributes.t option) -> Procdesc.t diff --git a/infer/src/checkers/annotations.ml b/infer/src/absint/annotations.ml similarity index 100% rename from infer/src/checkers/annotations.ml rename to infer/src/absint/annotations.ml diff --git a/infer/src/checkers/annotations.mli b/infer/src/absint/annotations.mli similarity index 100% rename from infer/src/checkers/annotations.mli rename to infer/src/absint/annotations.mli diff --git a/infer/src/backend/exe_env.ml b/infer/src/absint/exe_env.ml similarity index 100% rename from infer/src/backend/exe_env.ml rename to infer/src/absint/exe_env.ml diff --git a/infer/src/backend/exe_env.mli b/infer/src/absint/exe_env.mli similarity index 100% rename from infer/src/backend/exe_env.mli rename to infer/src/absint/exe_env.mli diff --git a/infer/src/absint/NodePrinter.ml b/infer/src/backend/NodePrinter.ml similarity index 100% rename from infer/src/absint/NodePrinter.ml rename to infer/src/backend/NodePrinter.ml diff --git a/infer/src/absint/NodePrinter.mli b/infer/src/backend/NodePrinter.mli similarity index 100% rename from infer/src/absint/NodePrinter.mli rename to infer/src/backend/NodePrinter.mli diff --git a/infer/src/absint/SummaryPayload.ml b/infer/src/backend/SummaryPayload.ml similarity index 100% rename from infer/src/absint/SummaryPayload.ml rename to infer/src/backend/SummaryPayload.ml diff --git a/infer/src/absint/SummaryPayload.mli b/infer/src/backend/SummaryPayload.mli similarity index 100% rename from infer/src/absint/SummaryPayload.mli rename to infer/src/backend/SummaryPayload.mli diff --git a/infer/src/backend/preanal.ml b/infer/src/checkers/preanal.ml similarity index 100% rename from infer/src/backend/preanal.ml rename to infer/src/checkers/preanal.ml diff --git a/infer/src/backend/preanal.mli b/infer/src/checkers/preanal.mli similarity index 100% rename from infer/src/backend/preanal.mli rename to infer/src/checkers/preanal.mli diff --git a/infer/src/nullsafe/typeCheck.ml b/infer/src/nullsafe/typeCheck.ml index 62fd11b70..b85254ad8 100644 --- a/infer/src/nullsafe/typeCheck.ml +++ b/infer/src/nullsafe/typeCheck.ml @@ -476,6 +476,27 @@ let typecheck_expr_for_errors ~nullsafe_mode find_canonical_duplicate curr_pdesc node instr_ref typestate1 exp1 Typ.void TypeOrigin.OptimisticFallback loc1) +(** Get the values of a vararg parameter given the pvar used to assign the elements by looking for + array assignments to the pvar. *) +let java_get_vararg_values node pvar idenv = + let values_of_instr acc = function + | Sil.Store {e1= Exp.Lindex (array_exp, _); e2= content_exp} + when Exp.equal (Exp.Lvar pvar) (Idenv.expand_expr idenv array_exp) -> + (* Each vararg argument is an assignment to a pvar denoting an array of objects. *) + content_exp :: acc + | _ -> + acc + in + let values_of_node acc n = + Procdesc.Node.get_instrs n |> Instrs.fold ~f:values_of_instr ~init:acc + in + match Errdesc.find_program_variable_assignment node pvar with + | Some (node', _) -> + Procdesc.fold_slope_range node' node ~f:values_of_node ~init:[] + | None -> + [] + + (* Handle Preconditions.checkNotNull. *) let do_preconditions_check_not_null instr_ref tenv find_canonical_duplicate node loc curr_pdesc curr_pname curr_annotated_signature checks call_params idenv parameter_num ~is_vararg typestate' @@ -529,7 +550,7 @@ let do_preconditions_check_not_null instr_ref tenv find_canonical_duplicate node | _ -> ts in - let vararg_values = PatternMatch.java_get_vararg_values node pvar idenv in + let vararg_values = java_get_vararg_values node pvar idenv in List.fold_right ~f:do_vararg_value vararg_values ~init:typestate' else pvar_apply instr_ref idenv tenv curr_pname curr_annotated_signature loc