From 4c2d5a4c496f86b9d6997ccf206f447d12f8570e Mon Sep 17 00:00:00 2001 From: Sungkeun Cho Date: Wed, 26 Aug 2020 06:27:37 -0700 Subject: [PATCH] [reanalyze] Fix reanalyze option Summary: This diff fixes `--reanalyze` option that is to reanalyze specific procedures by removing their summaries. It was broken because it tried to store an empty summary with `Status.Analyzed`. Reviewed By: ezgicicek Differential Revision: D23344633 fbshipit-source-id: 1c4eca6c0 --- infer/src/backend/Summary.ml | 15 ++++++++------- infer/src/backend/Summary.mli | 2 +- infer/src/backend/ondemand.ml | 4 ++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/infer/src/backend/Summary.ml b/infer/src/backend/Summary.ml index f7cc93781..2fa4a2a4e 100644 --- a/infer/src/backend/Summary.ml +++ b/infer/src/backend/Summary.ml @@ -268,24 +268,25 @@ module OnDisk = struct (** Save summary for the procedure into the spec database *) - let store (summ : t) = - let final_summary = {summ with status= Status.Analyzed} in - let proc_name = get_proc_name final_summary in + let store (summary : t) = + let proc_name = get_proc_name summary in (* Make sure the summary in memory is identical to the saved one *) - add proc_name final_summary ; + add proc_name summary ; if Config.biabduction_models_mode then Serialization.write_to_file summary_serializer (specs_filename_of_procname proc_name) - ~data:final_summary + ~data:summary else - let analysis_summary = AnalysisSummary.of_full_summary final_summary in - let report_summary = ReportSummary.of_full_summary final_summary in + let analysis_summary = AnalysisSummary.of_full_summary summary in + let report_summary = ReportSummary.of_full_summary summary in DBWriter.store_spec ~proc_name:(Procname.SQLite.serialize proc_name) ~analysis_summary:(AnalysisSummary.SQLite.serialize analysis_summary) ~report_summary:(ReportSummary.SQLite.serialize report_summary) + let store_analyzed summary = store {summary with status= Status.Analyzed} + let reset proc_desc = let summary = { sessions= 0 diff --git a/infer/src/backend/Summary.mli b/infer/src/backend/Summary.mli index d93163327..30a8c4b7b 100644 --- a/infer/src/backend/Summary.mli +++ b/infer/src/backend/Summary.mli @@ -73,7 +73,7 @@ module OnDisk : sig (** Try to find the attributes for a defined proc. First look at specs (to get attributes computed by analysis) then look at the attributes table. If no attributes can be found, return None. *) - val store : t -> unit + val store_analyzed : t -> unit (** Save summary for the procedure into the spec database *) val reset_all : filter:Filtering.procedures_filter -> unit -> unit diff --git a/infer/src/backend/ondemand.ml b/infer/src/backend/ondemand.ml index 5d708c862..d3b088c79 100644 --- a/infer/src/backend/ondemand.ml +++ b/infer/src/backend/ondemand.ml @@ -185,7 +185,7 @@ let run_proc_analysis ~caller_pdesc callee_pdesc = in let postprocess summary = decr nesting ; - Summary.OnDisk.store summary ; + Summary.OnDisk.store_analyzed summary ; remove_active callee_pname ; Printer.write_proc_html callee_pdesc ; log_elapsed_time () ; @@ -202,7 +202,7 @@ let run_proc_analysis ~caller_pdesc callee_pdesc = {summary.payloads with biabduction} in let new_summary = {summary with stats; payloads} in - Summary.OnDisk.store new_summary ; + Summary.OnDisk.store_analyzed new_summary ; remove_active callee_pname ; log_elapsed_time () ; new_summary