From dc29f8eecad542b757f97963dddfab24f756a96c Mon Sep 17 00:00:00 2001 From: Nikos Gorogiannis Date: Wed, 19 Aug 2020 03:51:16 -0700 Subject: [PATCH] [specs] fix reanalysis Summary: Moving specs to the DB missed out cleaning out all specs when reanalysing. This is the fix. Reviewed By: jvillard Differential Revision: D23188958 fbshipit-source-id: 5b50fdda8 --- infer/src/backend/InferAnalyze.ml | 2 +- infer/src/base/DB.ml | 9 --------- infer/src/base/DB.mli | 3 --- infer/src/base/DBWriter.ml | 12 ++++++++++++ infer/src/base/DBWriter.mli | 2 ++ 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/infer/src/backend/InferAnalyze.ml b/infer/src/backend/InferAnalyze.ml index 15122d726..cdfbb11af 100644 --- a/infer/src/backend/InferAnalyze.ml +++ b/infer/src/backend/InferAnalyze.ml @@ -225,7 +225,7 @@ let main ~changed_files = L.progress "Invalidating procedures to be reanalyzed@." ; Summary.OnDisk.reset_all ~filter:(Lazy.force Filtering.procedures_filter) () ; L.progress "Done@." ) - else if not Config.incremental_analysis then DB.Results_dir.clean_specs_dir () ; + else if not Config.incremental_analysis then DBWriter.delete_all_specs () ; let source_files = lazy (get_source_files_to_analyze ~changed_files) in (* empty all caches to minimize the process heap to have less work to do when forking *) clear_caches () ; diff --git a/infer/src/base/DB.ml b/infer/src/base/DB.ml index de75a901e..18cc6a17c 100644 --- a/infer/src/base/DB.ml +++ b/infer/src/base/DB.ml @@ -125,9 +125,6 @@ module Results_dir = struct filename_from_base base path - (** directory of spec files *) - let specs_dir = ResultsDir.get_path Specs - (** initialize the results directory *) let init ?(debug = false) source = if SourceFile.is_invalid source then L.(die InternalError) "Invalid source file passed" ; @@ -136,12 +133,6 @@ module Results_dir = struct Utils.create_dir (path_to_filename (Abs_source_dir source) []) ) - let clean_specs_dir () = - (* create dir just in case it doesn't exist to avoid errors *) - Utils.rmtree specs_dir ; - Utils.create_dir specs_dir - - (** create a file at the given path, creating any missing directories *) let create_file pk path = let rec create = function diff --git a/infer/src/base/DB.mli b/infer/src/base/DB.mli index 616144cb3..a52f4a5eb 100644 --- a/infer/src/base/DB.mli +++ b/infer/src/base/DB.mli @@ -45,9 +45,6 @@ module Results_dir : sig val init : ?debug:bool -> SourceFile.t -> unit (** Initialize the results directory *) - val clean_specs_dir : unit -> unit - (** Clean up specs directory *) - val create_file : path_kind -> path -> Unix.File_descr.t (** create a file at the given path, creating any missing directories *) end diff --git a/infer/src/base/DBWriter.ml b/infer/src/base/DBWriter.ml index 32bb6dce6..a1267658e 100644 --- a/infer/src/base/DBWriter.ml +++ b/infer/src/base/DBWriter.ml @@ -200,6 +200,11 @@ module Implementation = struct Sqlite3.bind delete_stmt 1 proc_name |> SqliteUtils.check_result_code db ~log:"delete spec bind proc_name" ; SqliteUtils.result_unit ~finalize:false ~log:"store spec" db delete_stmt ) + + + let delete_all_specs () = + let db = ResultsDatabase.get_database () in + SqliteUtils.exec db ~log:"drop procedures table" ~stmt:"DELETE FROM specs" end module Command = struct @@ -209,6 +214,7 @@ module Command = struct ; tenv: Sqlite3.Data.t ; integer_type_widths: Sqlite3.Data.t ; proc_names: Sqlite3.Data.t } + | DeleteAllSpecs | DeleteSpec of {proc_name: Sqlite3.Data.t} | Handshake | MarkAllSourceFilesStale @@ -230,6 +236,8 @@ module Command = struct let to_string = function | AddSourceFile _ -> "AddSourceFile" + | DeleteAllSpecs -> + "DeleteAllSpecs" | DeleteSpec _ -> "DeleteSpec" | Handshake -> @@ -255,6 +263,8 @@ module Command = struct let execute = function | AddSourceFile {source_file; tenv; integer_type_widths; proc_names} -> Implementation.add_source_file ~source_file ~tenv ~integer_type_widths ~proc_names + | DeleteAllSpecs -> + Implementation.delete_all_specs () | DeleteSpec {proc_name} -> Implementation.delete_spec ~proc_name | Handshake -> @@ -392,3 +402,5 @@ let store_spec ~proc_name ~analysis_summary ~report_summary = let delete_spec ~proc_name = perform (DeleteSpec {proc_name}) + +let delete_all_specs () = perform DeleteAllSpecs diff --git a/infer/src/base/DBWriter.mli b/infer/src/base/DBWriter.mli index cd6695f89..f369ada12 100644 --- a/infer/src/base/DBWriter.mli +++ b/infer/src/base/DBWriter.mli @@ -48,3 +48,5 @@ val store_spec : -> unit val delete_spec : proc_name:Sqlite3.Data.t -> unit + +val delete_all_specs : unit -> unit