[config] kill load/save analysis results

Summary: This feature is not used or tested.

Reviewed By: mbouaziz

Differential Revision: D6976229

fbshipit-source-id: 6880942
master
Jules Villard 7 years ago committed by Facebook Github Bot
parent 14fb188636
commit 2dbdf8f183

@ -873,9 +873,6 @@ let process_summary filters formats_by_report_kind linereader stats summary issu
issues_acc' issues_acc'
module AnalysisResults = struct
type t = (string * Specs.summary) list
let spec_files_from_cmdline () = let spec_files_from_cmdline () =
if CLOpt.is_originator then ( if CLOpt.is_originator then (
(* Find spec files specified by command-line arguments. Not run at init time since the specs (* Find spec files specified by command-line arguments. Not run at init time since the specs
@ -890,77 +887,20 @@ module AnalysisResults = struct
else load_specfiles () else load_specfiles ()
(** Load .specs files in memory and return list of summaries *)
let load_summaries_in_memory () : t =
let summaries = ref [] in
let load_file fname =
match Specs.load_summary (DB.filename_from_string fname) with
| None ->
L.(die UserError) "Error: cannot open file %s@." fname
| Some summary ->
summaries := (fname, summary) :: !summaries
in
let do_load () = spec_files_from_cmdline () |> List.iter ~f:load_file in
Utils.without_gc ~f:do_load ;
let summ_cmp (_, summ1) (_, summ2) =
let loc1 = Specs.get_loc summ1 and loc2 = Specs.get_loc summ2 in
let n = SourceFile.compare loc1.Location.file loc2.Location.file in
if n <> 0 then n else Int.compare loc1.Location.line loc2.Location.line
in
List.sort ~cmp:summ_cmp !summaries
(** Create an iterator which loads spec files one at a time *) (** Create an iterator which loads spec files one at a time *)
let iterator_of_spec_files () = let get_summary_iterator () =
let sorted_spec_files = List.sort ~cmp:String.compare (spec_files_from_cmdline ()) in let sorted_spec_files = List.sort ~cmp:String.compare (spec_files_from_cmdline ()) in
let do_spec f fname = let do_spec f fname =
match Specs.load_summary (DB.filename_from_string fname) with match Specs.load_summary (DB.filename_from_string fname) with
| None -> | None ->
L.(die UserError) "Error: cannot open file %s@." fname L.(die UserError) "Error: cannot open file %s@." fname
| Some summary -> | Some summary ->
f (fname, summary) f summary
in in
let iterate f = List.iter ~f:(do_spec f) sorted_spec_files in let iterate f = List.iter ~f:(do_spec f) sorted_spec_files in
iterate iterate
(** Serializer for analysis results *)
let analysis_results_serializer : t Serialization.serializer =
Serialization.create_serializer Serialization.Key.analysis_results
(** Load analysis_results from a file *)
let load_analysis_results_from_file (filename: DB.filename) : t option =
Serialization.read_from_file analysis_results_serializer filename
(** Save analysis_results into a file *)
let store_analysis_results_to_file (filename: DB.filename) (analysis_results: t) =
Serialization.write_to_file analysis_results_serializer filename ~data:analysis_results
(** Return an iterator over all the summaries.
If options - load_results or - save_results are used,
all the summaries are loaded in memory *)
let get_summary_iterator () =
let iterator_of_summary_list r f = List.iter ~f r in
match Config.load_analysis_results with
| None -> (
match Config.save_analysis_results with
| None ->
iterator_of_spec_files ()
| Some s ->
let r = load_summaries_in_memory () in
store_analysis_results_to_file (DB.filename_from_string s) r ;
iterator_of_summary_list r )
| Some fname ->
match load_analysis_results_from_file (DB.filename_from_string fname) with
| Some r ->
iterator_of_summary_list r
| None ->
L.(die UserError) "Error: cannot open analysis results file %s@." fname
end
let register_perf_stats_report () = let register_perf_stats_report () =
let stats_dir = Filename.concat Config.results_dir Config.reporting_stats_dir_name in let stats_dir = Filename.concat Config.results_dir Config.reporting_stats_dir_name in
let stats_file = Filename.concat stats_dir (Config.perf_stats_prefix ^ ".json") in let stats_file = Filename.concat stats_dir (Config.perf_stats_prefix ^ ".json") in
@ -1051,9 +991,9 @@ let pp_summary_and_issues formats_by_report_kind issue_formats =
let stats = Stats.create () in let stats = Stats.create () in
let linereader = Printer.LineReader.create () in let linereader = Printer.LineReader.create () in
let filters = Inferconfig.create_filters Config.analyzer in let filters = Inferconfig.create_filters Config.analyzer in
let iterate_summaries = AnalysisResults.get_summary_iterator () in let iterate_summaries = get_summary_iterator () in
let all_issues = ref [] in let all_issues = ref [] in
iterate_summaries (fun (_, summary) -> iterate_summaries (fun summary ->
all_issues all_issues
:= process_summary filters formats_by_report_kind linereader stats summary !all_issues ) ; := process_summary filters formats_by_report_kind linereader stats summary !all_issues ) ;
List.iter List.iter

@ -1455,12 +1455,6 @@ and load_average =
"Do not start new parallel jobs if the load average is greater than that specified (Buck and make only)" "Do not start new parallel jobs if the load average is greater than that specified (Buck and make only)"
and load_results =
CLOpt.mk_path_opt ~deprecated:["load_results"] ~long:"load-results"
~in_help:InferCommand.([(Report, manual_generic)])
~meta:"file.iar" "Load analysis results from Infer Analysis Results file file.iar"
and margin = and margin =
CLOpt.mk_int ~deprecated:["set_pp_margin"] ~long:"margin" ~default:100 ~meta:"int" CLOpt.mk_int ~deprecated:["set_pp_margin"] ~long:"margin" ~default:100 ~meta:"int"
"Set right margin for the pretty printing functions" "Set right margin for the pretty printing functions"
@ -1722,12 +1716,6 @@ and results_dir =
~meta:"dir" "Write results and internal files in the specified directory" ~meta:"dir" "Write results and internal files in the specified directory"
and save_results =
CLOpt.mk_path_opt ~deprecated:["save_results"] ~long:"save-results"
~in_help:InferCommand.([(Report, manual_generic)])
~meta:"file.iar" "Save analysis results to Infer Analysis Results file file.iar"
and seconds_per_iteration = and seconds_per_iteration =
CLOpt.mk_float_opt ~deprecated:["seconds_per_iteration"] ~long:"seconds-per-iteration" CLOpt.mk_float_opt ~deprecated:["seconds_per_iteration"] ~long:"seconds-per-iteration"
~meta:"float" "Set the number of seconds per iteration (see $(b,--iterations))" ~meta:"float" "Set the number of seconds per iteration (see $(b,--iterations))"
@ -2467,8 +2455,6 @@ and load_average =
match !load_average with None when !buck -> Some (float_of_int ncpu) | _ -> !load_average match !load_average with None when !buck -> Some (float_of_int ncpu) | _ -> !load_average
and load_analysis_results = !load_results
and log_events = !log_events and log_events = !log_events
and log_file = !log_file and log_file = !log_file
@ -2573,8 +2559,6 @@ and resource_leak = !resource_leak
and results_dir = !results_dir and results_dir = !results_dir
and save_analysis_results = !save_results
and seconds_per_iteration = !seconds_per_iteration and seconds_per_iteration = !seconds_per_iteration
and select = !select and select = !select

@ -467,8 +467,6 @@ val litho : bool
val liveness : bool val liveness : bool
val load_analysis_results : string option
val log_events : bool val log_events : bool
val log_file : string val log_file : string
@ -556,8 +554,6 @@ val resource_leak : bool
val results_dir : string val results_dir : string
val save_analysis_results : string option
val seconds_per_iteration : float option val seconds_per_iteration : float option
val select : int option val select : int option

@ -22,9 +22,9 @@ module Key = struct
(** Serialization key, used to distinguish versions of serializers and avoid assert faults *) (** Serialization key, used to distinguish versions of serializers and avoid assert faults *)
type t = int type t = int
(** Current keys for various serializable objects. The keys are computed using the [generate_keys] function below *) (** Current keys for various serializable objects. The keys are computed using the [generate_keys]
let tenv, summary, analysis_results, cluster, lint_issues = function below *)
(425184201, 160179325, 799050016, 579094948, 852343110) let tenv, summary, cluster, lint_issues = (425184201, 160179325, 579094948, 852343110)
end end
(** version of the binary files, to be incremented for each change *) (** version of the binary files, to be incremented for each change *)

@ -16,9 +16,6 @@ module Key : sig
(** Serialization key, used to distinguish versions of serializers and avoid assert faults *) (** Serialization key, used to distinguish versions of serializers and avoid assert faults *)
type t type t
val analysis_results : t
(** current key for an analysis results value *)
val cluster : t val cluster : t
(** current key for a cluster *) (** current key for a cluster *)

@ -350,15 +350,6 @@ let rec rmtree name =
() ()
let without_gc ~f =
let stat = Gc.get () in
let space_oh = stat.space_overhead in
Gc.set {stat with space_overhead= 10000} ;
let res = f () in
Gc.set {stat with space_overhead= space_oh} ;
res
let yield () = let yield () =
Unix.select ~read:[] ~write:[] ~except:[] ~timeout:(`After Time_ns.Span.min_value) |> ignore Unix.select ~read:[] ~write:[] ~except:[] ~timeout:(`After Time_ns.Span.min_value) |> ignore

@ -103,9 +103,6 @@ val try_finally_swallow_timeout : f:(unit -> 'a) -> finally:(unit -> unit) -> 'a
(** Calls [f] then [finally] even if [f] raised an exception. The original exception is reraised afterwards. (** Calls [f] then [finally] even if [f] raised an exception. The original exception is reraised afterwards.
Where possible use [SymOp.try_finally] to avoid swallowing timeouts. *) Where possible use [SymOp.try_finally] to avoid swallowing timeouts. *)
val without_gc : f:(unit -> unit) -> unit
(** Call [f ()] with the gc compaction disabled during the execution *)
val yield : unit -> unit val yield : unit -> unit
(** try to give the control back to the OS without sleeping too much *) (** try to give the control back to the OS without sleeping too much *)

Loading…
Cancel
Save