diff --git a/infer/src/backend/specs.ml b/infer/src/backend/specs.ml index 28996379c..585a06c96 100644 --- a/infer/src/backend/specs.ml +++ b/infer/src/backend/specs.ml @@ -337,7 +337,7 @@ type summary = proc_desc_option : Procdesc.t option; } -type spec_tbl = (summary * DB.origin) Procname.Hash.t +type spec_tbl = summary Procname.Hash.t let spec_tbl: spec_tbl = Procname.Hash.create 128 @@ -521,18 +521,12 @@ let payload_compact sh payload = let summary_compact sh summary = { summary with payload = payload_compact sh summary.payload } -let set_summary_origin proc_name summary origin = - Procname.Hash.replace spec_tbl proc_name (summary, origin) - -let add_summary_origin (proc_name : Procname.t) (summary: summary) (origin: DB.origin) : unit = +(** Add the summary to the table for the given function *) +let add_summary (proc_name : Procname.t) (summary: summary) : unit = L.out "Adding summary for %a@\n@[ %a@]@." Procname.pp proc_name (pp_summary_text ~whole_seconds:false) summary; - set_summary_origin proc_name summary origin - -(** Add the summary to the table for the given function *) -let add_summary (proc_name : Procname.t) (summary: summary) : unit = - add_summary_origin proc_name summary DB.Res_dir + Procname.Hash.replace spec_tbl proc_name summary let specs_filename pname = let pname_file = Procname.to_filename pname in @@ -578,25 +572,25 @@ let load_summary specs_file = (** Load procedure summary for the given procedure name and update spec table *) let load_summary_to_spec_table proc_name = - let add summ origin = - add_summary_origin proc_name summ origin; + let add summ = + add_summary proc_name summ; true in let load_summary_models models_dir = match load_summary models_dir with | None -> false - | Some summ -> add summ DB.Models in + | Some summ -> add summ in let rec load_summary_libs = function (* try to load the summary from a list of libs *) | [] -> false | spec_path :: spec_paths -> (match load_summary spec_path with | None -> load_summary_libs spec_paths | Some summ -> - add summ Spec_lib) in + add summ) in let load_summary_ziplibs zip_specs_filename = let zip_specs_path = Filename.concat Config.specs_dir_name zip_specs_filename in match ZipLib.load summary_serializer zip_specs_path with | None -> false - | Some (summary, origin) -> add summary origin in + | Some summary -> add summary in let default_spec_dir = res_dir_specs_filename proc_name in match load_summary default_spec_dir with | None -> @@ -605,21 +599,16 @@ let load_summary_to_spec_table proc_name = load_summary_ziplibs (specs_filename proc_name) || load_summary_libs (specs_library_filenames proc_name) | Some summ -> - add summ DB.Res_dir + add summ -let rec get_summary_origin proc_name = +let rec get_summary proc_name = try Some (Procname.Hash.find spec_tbl proc_name) with Not_found -> if load_summary_to_spec_table proc_name then - get_summary_origin proc_name + get_summary proc_name else None -let get_summary proc_name = - match get_summary_origin proc_name with - | Some (summary, _) -> Some summary - | None -> None - let get_summary_unsafe s proc_name = match get_summary proc_name with | None -> @@ -671,11 +660,6 @@ let pdesc_resolve_attributes proc_desc = (* this should not happen *) assert false -let is_model proc_name = - match get_summary_origin proc_name with - | None -> false - | Some (_, origin) -> origin = DB.Models - let summary_exists proc_name = match get_summary proc_name with | Some _ -> true @@ -729,9 +713,9 @@ let get_phase summary = (** Set the current status for the proc *) let set_status proc_name status = - match get_summary_origin proc_name with + match get_summary proc_name with | None -> raise (Failure ("Specs.set_status: " ^ (Procname.to_string proc_name) ^ " Not_found")) - | Some (summary, origin) -> set_summary_origin proc_name { summary with status = status } origin + | Some summary -> add_summary proc_name { summary with status = status } (** Create the initial dependency map with the given list of dependencies *) let mk_initial_dependency_map proc_list : dependency_map_t = @@ -744,16 +728,16 @@ let re_initialize_dependency_map dependency_map = (** Update the dependency map of [proc_name] with the current timestamps of the dependents *) let update_dependency_map proc_name = - match get_summary_origin proc_name with + match get_summary proc_name with | None -> raise (Failure ("Specs.update_dependency_map: " ^ (Procname.to_string proc_name) ^ " Not_found")) - | Some (summary, origin) -> + | Some summary -> let current_dependency_map = Procname.Map.mapi (fun _ _ -> get_timestamp summary) summary.dependency_map in - set_summary_origin proc_name { summary with dependency_map = current_dependency_map } origin + add_summary proc_name { summary with dependency_map = current_dependency_map } let empty_payload = { @@ -790,7 +774,7 @@ let init_summary ProcAttributes.proc_flags = proc_flags; }; proc_desc_option; } in - Procname.Hash.replace spec_tbl proc_attributes.ProcAttributes.proc_name (summary, DB.Res_dir) + Procname.Hash.replace spec_tbl proc_attributes.ProcAttributes.proc_name summary (** Reset a summary rebuilding the dependents and preserving the proc attributes if present. *) let reset_summary call_graph proc_name attributes_opt proc_desc_option = diff --git a/infer/src/backend/specs.mli b/infer/src/backend/specs.mli index 6eef3255d..7292f239f 100644 --- a/infer/src/backend/specs.mli +++ b/infer/src/backend/specs.mli @@ -162,9 +162,6 @@ val clear_spec_tbl : unit -> unit (** Dump a spec *) val d_spec : 'a spec -> unit -(** Returns true if the procedure is a model *) -val is_model: Procname.t -> bool - (** Return the summary option for the procedure name *) val get_summary : Procname.t -> summary option diff --git a/infer/src/base/DB.ml b/infer/src/base/DB.ml index 634c6b664..128938e77 100644 --- a/infer/src/base/DB.ml +++ b/infer/src/base/DB.ml @@ -209,12 +209,6 @@ module Results_dir = struct Unix.openfile full_fname ~mode:Unix.[O_WRONLY; O_CREAT; O_TRUNC] ~perm:0o777 end -(** origin of a analysis artifact: current results dir, a spec library, or models *) -type origin = - | Res_dir - | Spec_lib - | Models - let global_tenv_fname = let basename = Config.global_tenv_filename in filename_concat captured_dir basename diff --git a/infer/src/base/DB.mli b/infer/src/base/DB.mli index 8508d2d26..cfb35f5df 100644 --- a/infer/src/base/DB.mli +++ b/infer/src/base/DB.mli @@ -69,12 +69,6 @@ module Results_dir : sig val create_file : path_kind -> path -> Unix.File_descr.t end -(** origin of a analysis artifact: current results dir, a spec library, or models *) -type origin = - | Res_dir - | Spec_lib - | Models - (** {2 Source Dirs} *) (** source directory: the directory inside the results dir corresponding to a source file *) diff --git a/infer/src/base/ZipLib.ml b/infer/src/base/ZipLib.ml index 81ccd8261..691a740ec 100644 --- a/infer/src/base/ZipLib.ml +++ b/infer/src/base/ZipLib.ml @@ -37,8 +37,7 @@ let load_from_cache serializer zip_path cache_dir zip_library = end; DB.filename_from_string to_path in match deserialize (extract absolute_path) with - | Some data when zip_library.models -> Some (data, DB.Models) - | Some data -> Some (data, DB.Spec_lib) + | Some data -> Some data | None -> None | exception Not_found -> None @@ -46,8 +45,7 @@ let load_from_zip serializer zip_path zip_library = let lazy zip_channel = zip_library.zip_channel in let deserialize = Serialization.from_string serializer in match deserialize (Zip.read_entry zip_channel (Zip.find_entry zip_channel zip_path)) with - | Some data when zip_library.models -> Some (data, DB.Models) - | Some data -> Some (data, DB.Spec_lib) + | Some data -> Some data | None -> None | exception Not_found -> None diff --git a/infer/src/base/ZipLib.mli b/infer/src/base/ZipLib.mli index 608b700e5..942342af6 100644 --- a/infer/src/base/ZipLib.mli +++ b/infer/src/base/ZipLib.mli @@ -12,4 +12,4 @@ open! IStd (** [load serializer path] searches for the file at the given path in the zip libraries. If Config.infer_cache is set, already deserialized data will be saved there and [path] will be searched from the cache first. *) -val load : 'a Serialization.serializer -> string -> ('a * DB.origin) option +val load : 'a Serialization.serializer -> string -> 'a option