From 2dbdf8f183d3f95251e423ba9b18d7b729b87efa Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Tue, 13 Feb 2018 08:10:55 -0800 Subject: [PATCH] [config] kill load/save analysis results Summary: This feature is not used or tested. Reviewed By: mbouaziz Differential Revision: D6976229 fbshipit-source-id: 6880942 --- infer/src/backend/InferPrint.ml | 114 ++++++++----------------------- infer/src/base/Config.ml | 16 ----- infer/src/base/Config.mli | 4 -- infer/src/base/Serialization.ml | 6 +- infer/src/base/Serialization.mli | 3 - infer/src/base/Utils.ml | 9 --- infer/src/base/Utils.mli | 3 - 7 files changed, 30 insertions(+), 125 deletions(-) diff --git a/infer/src/backend/InferPrint.ml b/infer/src/backend/InferPrint.ml index ae4cb7dc6..4b06dd720 100644 --- a/infer/src/backend/InferPrint.ml +++ b/infer/src/backend/InferPrint.ml @@ -873,93 +873,33 @@ let process_summary filters formats_by_report_kind linereader stats summary issu issues_acc' -module AnalysisResults = struct - type t = (string * Specs.summary) list - - let spec_files_from_cmdline () = - if CLOpt.is_originator then ( - (* Find spec files specified by command-line arguments. Not run at init time since the specs +let spec_files_from_cmdline () = + if CLOpt.is_originator then ( + (* Find spec files specified by command-line arguments. Not run at init time since the specs files may be generated between init and report time. *) - List.iter - ~f:(fun arg -> - if not (Filename.check_suffix arg Config.specs_files_suffix) && arg <> "." then - print_usage_exit ("file " ^ arg ^ ": arguments must be .specs files") ) - Config.anon_args ; - if Config.test_filtering then ( Inferconfig.test () ; L.exit 0 ) ; - if List.is_empty Config.anon_args then load_specfiles () else List.rev Config.anon_args ) - 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 *) - let iterator_of_spec_files () = - let sorted_spec_files = List.sort ~cmp:String.compare (spec_files_from_cmdline ()) in - let do_spec f fname = - match Specs.load_summary (DB.filename_from_string fname) with - | None -> - L.(die UserError) "Error: cannot open file %s@." fname - | Some summary -> - f (fname, summary) - in - let iterate f = List.iter ~f:(do_spec f) sorted_spec_files in - 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 - + List.iter + ~f:(fun arg -> + if not (Filename.check_suffix arg Config.specs_files_suffix) && arg <> "." then + print_usage_exit ("file " ^ arg ^ ": arguments must be .specs files") ) + Config.anon_args ; + if Config.test_filtering then ( Inferconfig.test () ; L.exit 0 ) ; + if List.is_empty Config.anon_args then load_specfiles () else List.rev Config.anon_args ) + else load_specfiles () + + +(** Create an iterator which loads spec files one at a time *) +let get_summary_iterator () = + let sorted_spec_files = List.sort ~cmp:String.compare (spec_files_from_cmdline ()) in + let do_spec f fname = + match Specs.load_summary (DB.filename_from_string fname) with + | None -> + L.(die UserError) "Error: cannot open file %s@." fname + | Some summary -> + f summary + in + let iterate f = List.iter ~f:(do_spec f) sorted_spec_files in + iterate - (** 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 stats_dir = Filename.concat Config.results_dir Config.reporting_stats_dir_name in @@ -1051,9 +991,9 @@ let pp_summary_and_issues formats_by_report_kind issue_formats = let stats = Stats.create () in let linereader = Printer.LineReader.create () 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 - iterate_summaries (fun (_, summary) -> + iterate_summaries (fun summary -> all_issues := process_summary filters formats_by_report_kind linereader stats summary !all_issues ) ; List.iter diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index ea051fbf4..173b5ec1d 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -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)" -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 = CLOpt.mk_int ~deprecated:["set_pp_margin"] ~long:"margin" ~default:100 ~meta:"int" "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" -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 = CLOpt.mk_float_opt ~deprecated:["seconds_per_iteration"] ~long:"seconds-per-iteration" ~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 -and load_analysis_results = !load_results - and log_events = !log_events and log_file = !log_file @@ -2573,8 +2559,6 @@ and resource_leak = !resource_leak and results_dir = !results_dir -and save_analysis_results = !save_results - and seconds_per_iteration = !seconds_per_iteration and select = !select diff --git a/infer/src/base/Config.mli b/infer/src/base/Config.mli index fbed1bd68..27d1a2dd5 100644 --- a/infer/src/base/Config.mli +++ b/infer/src/base/Config.mli @@ -467,8 +467,6 @@ val litho : bool val liveness : bool -val load_analysis_results : string option - val log_events : bool val log_file : string @@ -556,8 +554,6 @@ val resource_leak : bool val results_dir : string -val save_analysis_results : string option - val seconds_per_iteration : float option val select : int option diff --git a/infer/src/base/Serialization.ml b/infer/src/base/Serialization.ml index 775433850..385855b6c 100644 --- a/infer/src/base/Serialization.ml +++ b/infer/src/base/Serialization.ml @@ -22,9 +22,9 @@ module Key = struct (** Serialization key, used to distinguish versions of serializers and avoid assert faults *) type t = int - (** Current keys for various serializable objects. The keys are computed using the [generate_keys] function below *) - let tenv, summary, analysis_results, cluster, lint_issues = - (425184201, 160179325, 799050016, 579094948, 852343110) + (** Current keys for various serializable objects. The keys are computed using the [generate_keys] + function below *) + let tenv, summary, cluster, lint_issues = (425184201, 160179325, 579094948, 852343110) end (** version of the binary files, to be incremented for each change *) diff --git a/infer/src/base/Serialization.mli b/infer/src/base/Serialization.mli index 049e0bddb..ac19a4740 100644 --- a/infer/src/base/Serialization.mli +++ b/infer/src/base/Serialization.mli @@ -16,9 +16,6 @@ module Key : sig (** Serialization key, used to distinguish versions of serializers and avoid assert faults *) type t - val analysis_results : t - (** current key for an analysis results value *) - val cluster : t (** current key for a cluster *) diff --git a/infer/src/base/Utils.ml b/infer/src/base/Utils.ml index ae302ef11..b0bf641fa 100644 --- a/infer/src/base/Utils.ml +++ b/infer/src/base/Utils.ml @@ -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 () = Unix.select ~read:[] ~write:[] ~except:[] ~timeout:(`After Time_ns.Span.min_value) |> ignore diff --git a/infer/src/base/Utils.mli b/infer/src/base/Utils.mli index acf3892c7..a0b01e9ec 100644 --- a/infer/src/base/Utils.mli +++ b/infer/src/base/Utils.mli @@ -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. 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 (** try to give the control back to the OS without sleeping too much *)