From bd1c3deac6a5a0e67428299bb59ff8f4b3449945 Mon Sep 17 00:00:00 2001 From: Phoebe Nichols Date: Thu, 4 Jul 2019 06:05:31 -0700 Subject: [PATCH] Remove proc_desc from iterate_procedure_callbacks Summary: `proc_desc` is an argument to the function `iterate_procedure_callbacks` in `callbacks.ml` but can always be obtained from another argument (`summary`) This commit removes the redundant argument Reviewed By: ngorogiannis Differential Revision: D16107332 fbshipit-source-id: 21c21921e --- infer/src/backend/callbacks.ml | 3 ++- infer/src/backend/callbacks.mli | 2 +- infer/src/backend/ondemand.ml | 25 +++++++++++++------------ 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/infer/src/backend/callbacks.ml b/infer/src/backend/callbacks.ml index 5f13760b0..dde6b8519 100644 --- a/infer/src/backend/callbacks.ml +++ b/infer/src/backend/callbacks.ml @@ -50,7 +50,8 @@ let get_procedure_definition exe_env proc_name = (** Invoke all registered procedure callbacks on the given procedure. *) -let iterate_procedure_callbacks exe_env summary proc_desc = +let iterate_procedure_callbacks exe_env summary = + let proc_desc = Summary.get_proc_desc summary in let proc_name = Procdesc.get_proc_name proc_desc in let procedure_language = Typ.Procname.get_language proc_name in Language.curr_language := procedure_language ; diff --git a/infer/src/backend/callbacks.mli b/infer/src/backend/callbacks.mli index f243f4b61..8b4254d3e 100644 --- a/infer/src/backend/callbacks.mli +++ b/infer/src/backend/callbacks.mli @@ -35,7 +35,7 @@ val register_procedure_callback : val register_cluster_callback : name:string -> Language.t -> cluster_callback_t -> unit (** register a cluster callback *) -val iterate_procedure_callbacks : Exe_env.t -> Summary.t -> Procdesc.t -> Summary.t +val iterate_procedure_callbacks : Exe_env.t -> Summary.t -> Summary.t (** Invoke all registered procedure callbacks on the given procedure. *) val iterate_cluster_callbacks : Typ.Procname.t sexp_list -> Exe_env.t -> SourceFile.t -> unit diff --git a/infer/src/backend/ondemand.ml b/infer/src/backend/ondemand.ml index 1719ae13d..f3a542dee 100644 --- a/infer/src/backend/ondemand.ml +++ b/infer/src/backend/ondemand.ml @@ -123,7 +123,8 @@ let restore_global_state st = (** reference to log errors only at the innermost recursive call *) let logged_error = ref false -let analyze summary callee_pdesc = +let analyze callee_summary = + let callee_pdesc = Summary.get_proc_desc callee_summary in let exe_env = Option.value_exn !exe_env_ref in let proc_name = Procdesc.get_proc_name callee_pdesc in let source_file = (Procdesc.get_attributes callee_pdesc).ProcAttributes.translation_unit in @@ -137,7 +138,7 @@ let analyze summary callee_pdesc = in current_taskbar_status := Some (t0, status) ; !ProcessPoolState.update_status t0 status ; - let summary = Callbacks.iterate_procedure_callbacks exe_env summary callee_pdesc in + let summary = Callbacks.iterate_procedure_callbacks exe_env callee_summary in if Topl.is_active () then Topl.add_errors exe_env summary ; summary @@ -157,8 +158,8 @@ let run_proc_analysis ~caller_pdesc callee_pdesc = Typ.Procname.pp callee_pname ; let preprocess () = incr nesting ; - let initial_summary = Summary.reset callee_pdesc in - add_active callee_pname ; initial_summary + let initial_callee_summary = Summary.reset callee_pdesc in + add_active callee_pname ; initial_callee_summary in let postprocess summary = decr nesting ; @@ -182,18 +183,18 @@ let run_proc_analysis ~caller_pdesc callee_pdesc = Summary.store new_summary ; remove_active callee_pname ; log_elapsed_time () ; new_summary in let old_state = save_global_state () in - let initial_summary = preprocess () in + let initial_callee_summary = preprocess () in let attributes = Procdesc.get_attributes callee_pdesc in try - let summary = - if attributes.ProcAttributes.is_defined then analyze initial_summary callee_pdesc - else initial_summary + let callee_summary = + if attributes.ProcAttributes.is_defined then analyze initial_callee_summary + else initial_callee_summary in - let final_summary = postprocess summary in + let final_callee_summary = postprocess callee_summary in restore_global_state old_state ; (* don't forget to reset this so we output messages for future errors too *) logged_error := false ; - final_summary + final_callee_summary with exn -> ( let backtrace = Printexc.get_backtrace () in IExn.reraise_if exn ~f:(fun () -> @@ -211,10 +212,10 @@ let run_proc_analysis ~caller_pdesc callee_pdesc = | SymOp.Analysis_failure_exe kind -> (* in production mode, log the timeout/crash and continue with the summary we had before the failure occurred *) - log_error_and_continue exn initial_summary kind + log_error_and_continue exn initial_callee_summary kind | _ -> (* this happens with assert false or some other unrecognized exception *) - log_error_and_continue exn initial_summary (FKcrash (Exn.to_string exn)) ) + log_error_and_continue exn initial_callee_summary (FKcrash (Exn.to_string exn)) ) (* shadowed for tracing *)