[infer][backend] remove duplicate function to store summaries to disk

Summary: The function `Checkers.ST.store_summary` was only used in one place. This revision moves the functionality to the only place where this function was used, except the part swallowing `Sys_error` which may have the bad side-effect of making issues like race-conditions silent.

Reviewed By: cristianoc

Differential Revision: D4608790

fbshipit-source-id: b84c8ce
master
Jeremy Dubreil 8 years ago committed by Facebook Github Bot
parent acd9e3246f
commit 7c85306e2f

@ -23,7 +23,7 @@ let analyze_exe_env exe_env => {
if Config.checkers {
/* run the checkers only */
let call_graph = Exe_env.get_cg exe_env;
Callbacks.iterate_callbacks Checkers.ST.store_summary call_graph exe_env;
Callbacks.iterate_callbacks call_graph exe_env;
Printer.write_all_html_files exe_env
} else {
/* run the full analysis */

@ -133,7 +133,7 @@ let iterate_cluster_callbacks all_procs exe_env proc_names =
!cluster_callbacks
(** Invoke all procedure and cluster callbacks on a given environment. *)
let iterate_callbacks store_summary call_graph exe_env =
let iterate_callbacks call_graph exe_env =
let procs_to_analyze =
(* analyze all the currently defined procedures *)
Cg.get_defined_nodes call_graph in
@ -178,6 +178,12 @@ let iterate_callbacks store_summary call_graph exe_env =
~f:(iterate_cluster_callbacks originally_defined_procs exe_env)
(cluster procs_to_analyze);
List.iter ~f:store_summary procs_to_analyze;
(* Store all the summaries to disk *)
List.iter
~f:(fun pname ->
let updated_summary_opt =
Option.map (Specs.get_summary pname) ~f:Specs.increment_timestamp in
Option.iter ~f:(Specs.store_summary pname) updated_summary_opt)
procs_to_analyze;
Config.curr_language := saved_language

@ -45,4 +45,4 @@ val register_cluster_callback : Config.language option -> cluster_callback_t ->
val unregister_all_callbacks : unit -> unit
(** Invoke all the registered callbacks. *)
val iterate_callbacks : (Procname.t -> unit) -> Cg.t -> Exe_env.t -> unit
val iterate_callbacks : Cg.t -> Exe_env.t -> unit

@ -673,6 +673,9 @@ let is_active summary =
let get_timestamp summary =
summary.timestamp
let increment_timestamp summary =
{ summary with timestamp = summary.timestamp + 1 }
let get_proc_name summary =
summary.attributes.ProcAttributes.proc_name

@ -201,6 +201,9 @@ val get_summary_unsafe : string -> Procname.t -> summary
(** Return the current timestamp for the summary *)
val get_timestamp : summary -> int
(** Increment the number of times a summary has been updated *)
val increment_timestamp : summary -> summary
(** Return the status (active v.s. inactive) of a procedure summary *)
val get_status : summary -> status

@ -55,15 +55,6 @@ module ST = struct
end
end
let store_summary proc_name =
Option.iter
~f:(fun summary ->
let summary' =
{ summary with
Specs.timestamp = summary.Specs.timestamp + 1 } in
try Specs.store_summary proc_name summary' with Sys_error s -> L.err "%s@." s)
(Specs.get_summary proc_name)
let report_error tenv
proc_name
proc_desc

@ -35,9 +35,6 @@ module ST : sig
string ->
unit
(** Store the summary to a .specs file. *)
val store_summary : Procname.t -> unit
end (* ST *)
module PP : sig

Loading…
Cancel
Save