From 9baea705481b05156efb03c26d2ed5e33583a303 Mon Sep 17 00:00:00 2001 From: Jeremy Dubreil Date: Thu, 3 Nov 2016 12:13:38 -0700 Subject: [PATCH] [infer][backend] More consistent API to check if a procedure is currently being analyzed Summary: For some reason, `Specs.is_active` was re-loading from the specs table the summary that should already be in scope. Reviewed By: cristianoc Differential Revision: D4124693 fbshipit-source-id: c0e9113 --- infer/src/backend/callbacks.ml | 9 +++++---- infer/src/backend/ondemand.ml | 5 +++-- infer/src/backend/specs.ml | 10 +++------- infer/src/backend/specs.mli | 5 +---- 4 files changed, 12 insertions(+), 17 deletions(-) diff --git a/infer/src/backend/callbacks.ml b/infer/src/backend/callbacks.ml index 3491295e0..d076ff628 100644 --- a/infer/src/backend/callbacks.ml +++ b/infer/src/backend/callbacks.ml @@ -179,9 +179,10 @@ let iterate_callbacks store_summary call_graph exe_env = (iterate_cluster_callbacks originally_defined_procs exe_env) (cluster procs_to_analyze); - IList.iter (fun proc_name -> - let tenv = Exe_env.get_tenv ~create:true exe_env proc_name in - store_summary tenv proc_name - ) procs_to_analyze; + IList.iter + (fun proc_name -> + let tenv = Exe_env.get_tenv ~create:true exe_env proc_name in + store_summary tenv proc_name) + procs_to_analyze; Config.curr_language := saved_language diff --git a/infer/src/backend/ondemand.ml b/infer/src/backend/ondemand.ml index 5317c6e15..e0a486315 100644 --- a/infer/src/backend/ondemand.ml +++ b/infer/src/backend/ondemand.ml @@ -54,8 +54,9 @@ let nesting = ref 0 let should_be_analyzed proc_attributes proc_name = let currently_analyzed () = - Specs.summary_exists proc_name && - Specs.is_active proc_name in + match Specs.get_summary proc_name with + | None -> false + | Some summary -> Specs.is_active summary in let already_analyzed () = match Specs.get_summary proc_name with | Some summary -> diff --git a/infer/src/backend/specs.ml b/infer/src/backend/specs.ml index 2560889e5..6f0c7520f 100644 --- a/infer/src/backend/specs.ml +++ b/infer/src/backend/specs.ml @@ -627,8 +627,7 @@ let get_summary proc_name = let get_summary_unsafe s proc_name = match get_summary proc_name with | None -> - raise (Failure ( - "[" ^ s ^ "] Specs.get_summary_unsafe: " ^ (Procname.to_string proc_name) ^ "Not_found")) + failwithf "[%s] Specs.get_summary_unsafe: %a Not found" s Procname.pp proc_name | Some summary -> summary (** Check if the procedure is from a library: @@ -689,11 +688,8 @@ let summary_exists proc_name = let get_status summary = summary.status -let is_active proc_name = - get_status (get_summary_unsafe "is_active" proc_name) = ACTIVE - -let is_inactive proc_name = - get_status (get_summary_unsafe "is_active" proc_name) = INACTIVE +let is_active summary = + get_status summary = ACTIVE let get_timestamp summary = summary.timestamp diff --git a/infer/src/backend/specs.mli b/infer/src/backend/specs.mli index 522bbee4c..253df11ea 100644 --- a/infer/src/backend/specs.mli +++ b/infer/src/backend/specs.mli @@ -205,10 +205,7 @@ val get_timestamp : summary -> int val get_status : summary -> status (** Check if the procedure is active *) -val is_active : Procname.t -> bool - -(** Check if the procedure is active *) -val is_inactive : Procname.t -> bool +val is_active : summary -> bool (** Initialize the summary for [proc_name] given dependent procs in list [depend_list]. Do nothing if a summary exists already. *)