diff --git a/infer/src/absint/NodePrinter.ml b/infer/src/absint/NodePrinter.ml index 00ad74393..3855ae962 100644 --- a/infer/src/absint/NodePrinter.ml +++ b/infer/src/absint/NodePrinter.ml @@ -13,7 +13,7 @@ open! IStd let new_session node = let pname = Procdesc.Node.get_proc_name node in let node_id = (Procdesc.Node.get_id node :> int) in - match Summary.get pname with + match Summary.OnDisk.get pname with | None -> 0 | Some summary -> diff --git a/infer/src/backend/InferAnalyze.ml b/infer/src/backend/InferAnalyze.ml index 3e860bf36..02a8fec24 100644 --- a/infer/src/backend/InferAnalyze.ml +++ b/infer/src/backend/InferAnalyze.ml @@ -13,7 +13,7 @@ module L = Logging let clear_caches () = Ondemand.clear_cache () ; - Summary.clear_cache () ; + Summary.OnDisk.clear_cache () ; Typ.Procname.SQLite.clear_cache () @@ -91,7 +91,7 @@ let main ~changed_files = register_active_checkers () ; if Config.reanalyze then ( L.progress "Invalidating procedures to be reanalyzed@." ; - Summary.reset_all ~filter:(Lazy.force Filtering.procedures_filter) () ; + Summary.OnDisk.reset_all ~filter:(Lazy.force Filtering.procedures_filter) () ; L.progress "Done@." ) else DB.Results_dir.clean_specs_dir () ; let n_all_source_files = ref 0 in diff --git a/infer/src/backend/SpecsFiles.ml b/infer/src/backend/SpecsFiles.ml index aaabb41ba..6ffe28256 100644 --- a/infer/src/backend/SpecsFiles.ml +++ b/infer/src/backend/SpecsFiles.ml @@ -50,7 +50,7 @@ let spec_files_from_cmdline () = let summary_iterator spec_files = let sorted_spec_files = List.sort ~compare:String.compare (spec_files ()) in let do_spec f fname = - match Summary.load_from_file (DB.filename_from_string fname) with + match Summary.OnDisk.load_from_file (DB.filename_from_string fname) with | None -> L.(die UserError) "Error: cannot open file %s@." fname | Some summary -> @@ -65,5 +65,7 @@ let iter_from_config ~f = summary_iterator spec_files_from_cmdline f let iter ~f = summary_iterator load_specfiles f let delete pname = - let filename = Summary.specs_filename_of_procname pname |> DB.filename_to_string in - Unix.unlink filename ; Ondemand.remove_from_cache pname ; Summary.remove_from_cache pname + let filename = Summary.OnDisk.specs_filename_of_procname pname |> DB.filename_to_string in + Unix.unlink filename ; + Ondemand.remove_from_cache pname ; + Summary.OnDisk.remove_from_cache pname diff --git a/infer/src/backend/Summary.ml b/infer/src/backend/Summary.ml index 22ea72466..fb209163c 100644 --- a/infer/src/backend/Summary.ml +++ b/infer/src/backend/Summary.ml @@ -8,7 +8,6 @@ open! IStd module F = Format -open PolyVariantEqual module Stats = struct type t = @@ -96,14 +95,6 @@ let get_err_log summary = summary.err_log let get_loc summary = (get_attributes summary).ProcAttributes.loc -type cache = t Typ.Procname.Hash.t - -let cache : cache = Typ.Procname.Hash.create 128 - -let clear_cache () = Typ.Procname.Hash.clear cache - -let remove_from_cache pname = Typ.Procname.Hash.remove cache pname - let pp_errlog fmt err_log = F.fprintf fmt "ERRORS: @[%a@]@\n%!" Errlog.pp_errors err_log ; F.fprintf fmt "WARNINGS: @[%a@]" Errlog.pp_warnings err_log @@ -139,142 +130,155 @@ let pp_html source fmt summary = F.fprintf fmt "@\n" -(** Add the summary to the table for the given function *) -let add (proc_name : Typ.Procname.t) (summary : t) : unit = - Typ.Procname.Hash.replace cache proc_name summary +module OnDisk = struct + open PolyVariantEqual + type cache = t Typ.Procname.Hash.t -let specs_filename pname = - let pname_file = Typ.Procname.to_filename pname in - pname_file ^ Config.specs_files_suffix + let cache : cache = Typ.Procname.Hash.create 128 + let clear_cache () = Typ.Procname.Hash.clear cache -(** Return the path to the .specs file for the given procedure in the current results directory *) -let specs_filename_of_procname pname = - DB.Results_dir.path_to_filename DB.Results_dir.Abs_root - [Config.specs_dir_name; specs_filename pname] + let remove_from_cache pname = Typ.Procname.Hash.remove cache pname + (** Add the summary to the table for the given function *) + let add (proc_name : Typ.Procname.t) (summary : t) : unit = + Typ.Procname.Hash.replace cache proc_name summary -(** paths to the .specs file for the given procedure in the current spec libraries *) -let specs_library_filename specs_dir pname = - DB.filename_from_string (Filename.concat specs_dir (specs_filename pname)) + let specs_filename pname = + let pname_file = Typ.Procname.to_filename pname in + pname_file ^ Config.specs_files_suffix -(** paths to the .specs file for the given procedure in the models folder *) -let specs_models_filename pname = - DB.filename_from_string (Filename.concat Config.models_dir (specs_filename pname)) + (** Return the path to the .specs file for the given procedure in the current results directory *) + let specs_filename_of_procname pname = + DB.Results_dir.path_to_filename DB.Results_dir.Abs_root + [Config.specs_dir_name; specs_filename pname] -let has_model pname = Sys.file_exists (DB.filename_to_string (specs_models_filename pname)) = `Yes -let summary_serializer : t Serialization.serializer = - Serialization.create_serializer Serialization.Key.summary + (** paths to the .specs file for the given procedure in the current spec libraries *) + let specs_library_filename specs_dir pname = + DB.filename_from_string (Filename.concat specs_dir (specs_filename pname)) -(** Load procedure summary from the given file *) -let load_from_file specs_file = Serialization.read_from_file summary_serializer specs_file + (** paths to the .specs file for the given procedure in the models folder *) + let specs_models_filename pname = + DB.filename_from_string (Filename.concat Config.models_dir (specs_filename pname)) -(** Load procedure summary for the given procedure name and update spec table *) -let load_summary_to_spec_table = - let rec or_load_summary_libs specs_dirs proc_name summ_opt = - match (summ_opt, specs_dirs) with - | Some _, _ | _, [] -> - summ_opt - | None, specs_dir :: specs_dirs -> - load_from_file (specs_library_filename specs_dir proc_name) - |> or_load_summary_libs specs_dirs proc_name - in - let load_summary_ziplibs zip_specs_filename = - let zip_specs_path = Filename.concat Config.specs_dir_name zip_specs_filename in - ZipLib.load summary_serializer zip_specs_path - in - let or_from f_load f_filenames proc_name summ_opt = - match summ_opt with Some _ -> summ_opt | None -> f_load (f_filenames proc_name) - in - fun proc_name -> - let summ_opt = - load_from_file (specs_filename_of_procname proc_name) - |> or_from load_from_file specs_models_filename proc_name - |> or_from load_summary_ziplibs specs_filename proc_name - |> or_load_summary_libs Config.specs_library proc_name - in - Option.iter ~f:(add proc_name) summ_opt ; - summ_opt + let has_model pname = + Sys.file_exists (DB.filename_to_string (specs_models_filename pname)) = `Yes -let get proc_name = - try Some (Typ.Procname.Hash.find cache proc_name) - with Caml.Not_found -> load_summary_to_spec_table proc_name + let summary_serializer : t Serialization.serializer = + Serialization.create_serializer Serialization.Key.summary -(** Check if the procedure is from a library: + + (** Load procedure summary from the given file *) + let load_from_file specs_file = Serialization.read_from_file summary_serializer specs_file + + (** Load procedure summary for the given procedure name and update spec table *) + let load_summary_to_spec_table = + let rec or_load_summary_libs specs_dirs proc_name summ_opt = + match (summ_opt, specs_dirs) with + | Some _, _ | _, [] -> + summ_opt + | None, specs_dir :: specs_dirs -> + load_from_file (specs_library_filename specs_dir proc_name) + |> or_load_summary_libs specs_dirs proc_name + in + let load_summary_ziplibs zip_specs_filename = + let zip_specs_path = Filename.concat Config.specs_dir_name zip_specs_filename in + ZipLib.load summary_serializer zip_specs_path + in + let or_from f_load f_filenames proc_name summ_opt = + match summ_opt with Some _ -> summ_opt | None -> f_load (f_filenames proc_name) + in + fun proc_name -> + let summ_opt = + load_from_file (specs_filename_of_procname proc_name) + |> or_from load_from_file specs_models_filename proc_name + |> or_from load_summary_ziplibs specs_filename proc_name + |> or_load_summary_libs Config.specs_library proc_name + in + Option.iter ~f:(add proc_name) summ_opt ; + summ_opt + + + let get proc_name = + match Typ.Procname.Hash.find cache proc_name with + | summary -> + Some summary + | exception Caml.Not_found -> + load_summary_to_spec_table proc_name + + + (** Check if the procedure is from a library: It's not defined, and there is no spec file for it. *) -let proc_is_library proc_attributes = - if not proc_attributes.ProcAttributes.is_defined then - match get proc_attributes.ProcAttributes.proc_name with None -> true | Some _ -> false - else false + let proc_is_library proc_attributes = + if not proc_attributes.ProcAttributes.is_defined then + match get proc_attributes.ProcAttributes.proc_name with None -> true | Some _ -> false + else false -(** Try to find the attributes for a defined proc. + (** 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. *) -let proc_resolve_attributes proc_name = - match get proc_name with - | Some summary -> - Some (get_attributes summary) - | None -> - Attributes.load proc_name - - -(** 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 - (* Make sure the summary in memory is identical to the saved one *) - add proc_name final_summary ; - Serialization.write_to_file summary_serializer - (specs_filename_of_procname proc_name) - ~data:final_summary - - -let init_summary proc_desc = - let summary = - { sessions= ref 0 - ; payloads= Payloads.empty - ; stats= Stats.empty - ; status= Status.Pending - ; proc_desc - ; err_log= Errlog.empty () - ; callee_pnames= Typ.Procname.Set.empty } - in - Typ.Procname.Hash.replace cache (Procdesc.get_proc_name proc_desc) summary ; - summary - - -let dummy = - let dummy_attributes = - ProcAttributes.default (SourceFile.invalid __FILE__) Typ.Procname.empty_block - in - let dummy_proc_desc = Procdesc.from_proc_attributes dummy_attributes in - init_summary dummy_proc_desc - - -(** Reset a summary rebuilding the dependents and preserving the proc attributes if present. *) -let reset proc_desc = init_summary proc_desc - -let reset_all ~filter () = - let reset proc_name = - let filename = specs_filename_of_procname proc_name in - Serialization.read_from_file summary_serializer filename - |> Option.iter ~f:(fun summary -> - let blank_summary = reset summary.proc_desc in - Serialization.write_to_file summary_serializer filename ~data:blank_summary ) - in - Procedures.get_all ~filter () |> List.iter ~f:reset + let proc_resolve_attributes proc_name = + match get proc_name with + | Some summary -> + Some (get_attributes summary) + | None -> + Attributes.load proc_name + + + (** 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 + (* Make sure the summary in memory is identical to the saved one *) + add proc_name final_summary ; + Serialization.write_to_file summary_serializer + (specs_filename_of_procname proc_name) + ~data:final_summary + + + let reset proc_desc = + let summary = + { sessions= ref 0 + ; payloads= Payloads.empty + ; stats= Stats.empty + ; status= Status.Pending + ; proc_desc + ; err_log= Errlog.empty () + ; callee_pnames= Typ.Procname.Set.empty } + in + Typ.Procname.Hash.replace cache (Procdesc.get_proc_name proc_desc) summary ; + summary + let dummy = + let dummy_attributes = + ProcAttributes.default (SourceFile.invalid __FILE__) Typ.Procname.empty_block + in + let dummy_proc_desc = Procdesc.from_proc_attributes dummy_attributes in + reset dummy_proc_desc + + + let reset_all ~filter () = + let reset proc_name = + let filename = specs_filename_of_procname proc_name in + Serialization.read_from_file summary_serializer filename + |> Option.iter ~f:(fun summary -> + let blank_summary = reset summary.proc_desc in + Serialization.write_to_file summary_serializer filename ~data:blank_summary ) + in + Procedures.get_all ~filter () |> List.iter ~f:reset +end + module SummaryValue = struct type nonrec t = t option diff --git a/infer/src/backend/Summary.mli b/infer/src/backend/Summary.mli index d922bab64..e33e3c3b0 100644 --- a/infer/src/backend/Summary.mli +++ b/infer/src/backend/Summary.mli @@ -51,22 +51,6 @@ type t = val poly_fields : t PolyFields.t -val dummy : t -(** dummy summary for testing *) - -val has_model : Typ.Procname.t -> bool -(** Check if a summary for a given procedure exists in the models directory *) - -val clear_cache : unit -> unit -(** Remove all the elements from the cache of summaries *) - -val remove_from_cache : Typ.Procname.t -> unit -(** Remove an element from the cache of summaries. Contrast to reset which re-initializes a summary - keeping the same Procdesc and updates the cache accordingly. *) - -val get : Typ.Procname.t -> t option -(** Return the summary option for the procedure name *) - val get_proc_name : t -> Typ.Procname.t (** Get the procedure name *) @@ -88,36 +72,54 @@ val get_signature : t -> string val get_status : t -> Status.t (** Return the status (active v.s. inactive) of a procedure summary *) -val reset : Procdesc.t -> t -(** Reset a summary rebuilding the dependents and preserving the proc attributes if present. *) - -val specs_filename_of_procname : Typ.Procname.t -> DB.filename -(** Return the path to the .specs file for the given procedure in the current results directory *) - -val load_from_file : DB.filename -> t option -(** Load procedure summary from the given file *) - val pp_html : SourceFile.t -> Format.formatter -> t -> unit (** Print the summary in html format *) val pp_text : Format.formatter -> t -> unit (** Print the summary in text format *) -val proc_resolve_attributes : Typ.Procname.t -> ProcAttributes.t option -(** Try to find the attributes for a defined proc. +module OnDisk : sig + val has_model : Typ.Procname.t -> bool + (** Check if a summary for a given procedure exists in the models directory *) + + val clear_cache : unit -> unit + (** Remove all the elements from the cache of summaries *) + + val remove_from_cache : Typ.Procname.t -> unit + (** Remove an element from the cache of summaries. Contrast to reset which re-initializes a summary + keeping the same Procdesc and updates the cache accordingly. *) + + val get : Typ.Procname.t -> t option + (** Return the summary option for the procedure name *) + + val reset : Procdesc.t -> t + (** Reset a summary rebuilding the dependents and preserving the proc attributes if present. *) + + val specs_filename_of_procname : Typ.Procname.t -> DB.filename + (** Return the path to the .specs file for the given procedure in the current results directory *) + + val load_from_file : DB.filename -> t option + (** Load procedure summary from the given file *) + + val proc_resolve_attributes : Typ.Procname.t -> ProcAttributes.t option + (** 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 proc_is_library : ProcAttributes.t -> bool -(** Check if the procedure is from a library: + val proc_is_library : ProcAttributes.t -> bool + (** Check if the procedure is from a library: It's not defined, and there is no spec file for it. *) -val store : t -> unit -(** Save summary for the procedure into the spec database *) + val store : t -> unit + (** Save summary for the procedure into the spec database *) -val reset_all : filter:Filtering.procedures_filter -> unit -> unit + val reset_all : filter:Filtering.procedures_filter -> unit -> unit + + val dummy : t + (** dummy summary for testing *) +end module SummaryValue : Memcached.Value with type t = t option diff --git a/infer/src/backend/callbacks.ml b/infer/src/backend/callbacks.ml index 2b64f5820..f085f0247 100644 --- a/infer/src/backend/callbacks.ml +++ b/infer/src/backend/callbacks.ml @@ -42,7 +42,7 @@ let get_procedure_definition exe_env proc_name = Procdesc.load proc_name |> Option.map ~f:(fun proc_desc -> let tenv = Exe_env.get_tenv exe_env proc_name in - (tenv, Summary.reset proc_desc) ) + (tenv, Summary.OnDisk.reset proc_desc) ) (** Invoke all registered procedure callbacks on the given procedure. *) diff --git a/infer/src/backend/ondemand.ml b/infer/src/backend/ondemand.ml index 2425cf748..2ccfb0b66 100644 --- a/infer/src/backend/ondemand.ml +++ b/infer/src/backend/ondemand.ml @@ -41,7 +41,7 @@ let is_active, add_active, remove_active = let already_analyzed proc_name = - match Summary.get proc_name with + match Summary.OnDisk.get proc_name with | Some summary -> Summary.(Status.is_analyzed (get_status summary)) | None -> @@ -57,7 +57,7 @@ let should_be_analyzed proc_attributes = let get_proc_attr proc_name = IList.force_until_first_some - [lazy (Summary.proc_resolve_attributes proc_name); lazy (Topl.get_proc_attr proc_name)] + [lazy (Summary.OnDisk.proc_resolve_attributes proc_name); lazy (Topl.get_proc_attr proc_name)] let procedure_should_be_analyzed proc_name = @@ -158,12 +158,12 @@ let run_proc_analysis ~caller_pdesc callee_pdesc = Typ.Procname.pp callee_pname ; let preprocess () = incr nesting ; - let initial_callee_summary = Summary.reset callee_pdesc in + let initial_callee_summary = Summary.OnDisk.reset callee_pdesc in add_active callee_pname ; initial_callee_summary in let postprocess summary = decr nesting ; - Summary.store summary ; + Summary.OnDisk.store summary ; remove_active callee_pname ; Printer.write_proc_html callee_pdesc ; log_elapsed_time () ; @@ -180,7 +180,10 @@ let run_proc_analysis ~caller_pdesc callee_pdesc = {summary.payloads with biabduction} in let new_summary = {summary with stats; payloads} in - Summary.store new_summary ; remove_active callee_pname ; log_elapsed_time () ; new_summary + Summary.OnDisk.store new_summary ; + remove_active callee_pname ; + log_elapsed_time () ; + new_summary in let old_state = save_global_state () in let initial_callee_summary = preprocess () in @@ -293,7 +296,7 @@ let register_callee ?caller_summary callee_pname = let get_proc_desc callee_pname = IList.force_until_first_some [ lazy (Procdesc.load callee_pname) - ; lazy (Option.map ~f:Summary.get_proc_desc (Summary.get callee_pname)) + ; lazy (Option.map ~f:Summary.get_proc_desc (Summary.OnDisk.get callee_pname)) ; lazy (Topl.get_proc_desc callee_pname) ] @@ -318,10 +321,10 @@ let analyze_proc ?caller_summary callee_pname callee_pdesc should_be_analyzed = callee_pdesc) , true ) | None -> - (Summary.get callee_pname, true) + (Summary.OnDisk.get callee_pname, true) else ( EventLogger.log_skipped_pname (F.asprintf "%a" Typ.Procname.pp callee_pname) ; - (Summary.get callee_pname, true) ) + (Summary.OnDisk.get callee_pname, true) ) in if update_memcached then memcache_set callee_pname callee_summary_option ; Typ.Procname.Hash.add cache callee_pname callee_summary_option ; diff --git a/infer/src/backend/preanal.ml b/infer/src/backend/preanal.ml index 262361018..ad845c63d 100644 --- a/infer/src/backend/preanal.ml +++ b/infer/src/backend/preanal.ml @@ -209,7 +209,7 @@ let do_funptr_sub summary tenv = let do_preanalysis pdesc tenv = - let summary = Summary.reset pdesc in + let summary = Summary.OnDisk.reset pdesc in if Config.function_pointer_specialization && not (Typ.Procname.is_java (Procdesc.get_proc_name pdesc)) diff --git a/infer/src/backend/printer.ml b/infer/src/backend/printer.ml index ad81a18a1..be0270ebb 100644 --- a/infer/src/backend/printer.ml +++ b/infer/src/backend/printer.ml @@ -69,7 +69,7 @@ let curr_html_formatter = ref F.std_formatter (** Return true if the node was visited during analysis *) let is_visited node = - match Summary.get (Procdesc.Node.get_proc_name node) with + match Summary.OnDisk.get (Procdesc.Node.get_proc_name node) with | None -> false | Some summary -> @@ -182,7 +182,7 @@ end = struct []) linenum ; pp_node_link_seq [] ~description:true fmt nodes ; - ( match Summary.get pname with + ( match Summary.OnDisk.get pname with | None -> () | Some summary -> @@ -230,7 +230,7 @@ end = struct Hashtbl.replace table_nodes_at_linenum lnum (n :: curr_nodes) in List.iter ~f:process_node (Procdesc.get_nodes proc_desc) ; - match Summary.get proc_name with + match Summary.OnDisk.get proc_name with | None -> () | Some summary -> @@ -259,7 +259,7 @@ end = struct | Procdesc.Node.Start_node -> let proc_name = Procdesc.Node.get_proc_name n in let proc_name_escaped = Escape.escape_xml (Typ.Procname.to_string proc_name) in - if Summary.get proc_name |> Option.is_some then ( + if Summary.OnDisk.get proc_name |> Option.is_some then ( F.pp_print_char fmt ' ' ; let label = F.asprintf "summary for %s" proc_name_escaped in Io_infer.Html.pp_proc_link [fname_encoding] proc_name fmt label ) diff --git a/infer/src/backend/reporting.ml b/infer/src/backend/reporting.ml index 6bc73950d..121558b73 100644 --- a/infer/src/backend/reporting.ml +++ b/infer/src/backend/reporting.ml @@ -59,7 +59,7 @@ let log_issue_from_summary severity summary ~node ~session ~loc ~ltr ?extras exn let log_issue_deprecated_using_state severity proc_name ?node ?loc ?ltr exn = if !BiabductionConfig.footprint then - match Summary.get proc_name with + match Summary.OnDisk.get proc_name with | Some summary -> let node = let node = match node with None -> State.get_node_exn () | Some node -> node in diff --git a/infer/src/biabduction/SymExec.ml b/infer/src/biabduction/SymExec.ml index 98d3b02b5..204325f3b 100644 --- a/infer/src/biabduction/SymExec.ml +++ b/infer/src/biabduction/SymExec.ml @@ -519,7 +519,7 @@ let method_exists right_proc_name methods = | Some attrs -> attrs.ProcAttributes.is_defined | None -> - Summary.has_model right_proc_name + Summary.OnDisk.has_model right_proc_name let resolve_method tenv class_name proc_name = @@ -1125,7 +1125,7 @@ let resolve_and_analyze_clang current_summary tenv prop_r n_actual_params callee (* to be extended to other methods *) then try - let has_clang_model = Summary.has_model callee_pname in + let has_clang_model = Summary.OnDisk.has_model callee_pname in let resolve_and_analyze_result = resolve_and_analyze tenv ~caller_summary:current_summary ~has_clang_model prop_r n_actual_params callee_pname call_flags @@ -1721,7 +1721,7 @@ and unknown_or_scan_call ~is_scan ~reason ret_typ ret_annots let callee_loc_opt = Option.map ~f:(fun attributes -> attributes.ProcAttributes.loc) - (Summary.proc_resolve_attributes callee_pname) + (Summary.OnDisk.proc_resolve_attributes callee_pname) in let skip_path = Paths.Path.add_skipped_call path callee_pname reason callee_loc_opt in [(prop_with_undef_attr, skip_path)] @@ -1763,7 +1763,7 @@ and check_variadic_sentinel ?(fails_on_nil = false) n_formals (sentinel, null_po and check_variadic_sentinel_if_present ({Builtin.prop_; path; proc_name} as builtin_args) = - match Summary.proc_resolve_attributes proc_name with + match Summary.OnDisk.proc_resolve_attributes proc_name with | None -> [(prop_, path)] | Some callee_attributes -> ( diff --git a/infer/src/biabduction/Tabulation.ml b/infer/src/biabduction/Tabulation.ml index a418afff2..30f606cd2 100644 --- a/infer/src/biabduction/Tabulation.ml +++ b/infer/src/biabduction/Tabulation.ml @@ -834,7 +834,7 @@ let prop_set_exn tenv pname prop se_exn = (** Include a subtrace for a procedure call if the callee is not a model. *) let include_subtrace callee_pname = - match Summary.proc_resolve_attributes callee_pname with + match Summary.OnDisk.proc_resolve_attributes callee_pname with | Some attrs -> (not attrs.ProcAttributes.is_model) && SourceFile.is_under_project_root attrs.ProcAttributes.loc.Location.file diff --git a/infer/src/checkers/NullabilityPreanalysis.ml b/infer/src/checkers/NullabilityPreanalysis.ml index b2b9fbb6f..3010bd572 100644 --- a/infer/src/checkers/NullabilityPreanalysis.ml +++ b/infer/src/checkers/NullabilityPreanalysis.ml @@ -96,9 +96,8 @@ let analysis cfg tenv = let f proc_name pdesc domain = if Procdesc.is_defined pdesc && Typ.Procname.is_constructor proc_name then match - FieldsAssignedInConstructorsChecker.compute_post - (ProcData.make (Summary.reset pdesc) tenv (Ident.Hash.create 10)) - ~initial + FieldsAssignedInConstructorsChecker.compute_post ~initial + (ProcData.make (Summary.OnDisk.reset pdesc) tenv (Ident.Hash.create 10)) with | Some new_domain -> FieldsAssignedInConstructors.union new_domain domain diff --git a/infer/src/checkers/annotationReachability.ml b/infer/src/checkers/annotationReachability.ml index edb8cf276..c700e95b7 100644 --- a/infer/src/checkers/annotationReachability.ml +++ b/infer/src/checkers/annotationReachability.ml @@ -51,7 +51,8 @@ let is_allocator tenv pname = let check_attributes check tenv pname = PatternMatch.check_class_attributes check tenv pname - || Annotations.pname_has_return_annot pname ~attrs_of_pname:Summary.proc_resolve_attributes check + || Annotations.pname_has_return_annot pname + ~attrs_of_pname:Summary.OnDisk.proc_resolve_attributes check let method_overrides is_annotated tenv pname = diff --git a/infer/src/clang/cFrontend_decl.ml b/infer/src/clang/cFrontend_decl.ml index d26ec0c38..fb8178f84 100644 --- a/infer/src/clang/cFrontend_decl.ml +++ b/infer/src/clang/cFrontend_decl.ml @@ -41,7 +41,7 @@ let protect ~f ~recover ~pp_context (trans_unit_ctx : CFrontend_config.translati module CFrontend_decl_funct (T : CModule_type.CTranslation) : CModule_type.CFrontend = struct - let model_exists procname = (not Config.models_mode) && Summary.has_model procname + let model_exists procname = (not Config.models_mode) && Summary.OnDisk.has_model procname (** Translates the method/function's body into nodes of the cfg. *) let add_method ?(is_destructor_wrapper = false) trans_unit_ctx tenv cfg class_decl_opt procname diff --git a/infer/src/concurrency/RacerD.ml b/infer/src/concurrency/RacerD.ml index ede7fcb3f..5dd551792 100644 --- a/infer/src/concurrency/RacerD.ml +++ b/infer/src/concurrency/RacerD.ml @@ -524,7 +524,7 @@ let analyze_procedure {Callbacks.exe_env; summary} = let initial = let threads = if - runs_on_ui_thread ~attrs_of_pname:Summary.proc_resolve_attributes tenv proc_desc + runs_on_ui_thread ~attrs_of_pname:Summary.OnDisk.proc_resolve_attributes tenv proc_desc |> Option.is_some || is_thread_confined_method tenv proc_desc then ThreadsDomain.AnyThreadButSelf diff --git a/infer/src/concurrency/RacerDModels.ml b/infer/src/concurrency/RacerDModels.ml index b687e30aa..4a72cfb4e 100644 --- a/infer/src/concurrency/RacerDModels.ml +++ b/infer/src/concurrency/RacerDModels.ml @@ -155,7 +155,8 @@ let should_skip = let has_return_annot predicate pn = - Annotations.pname_has_return_annot pn ~attrs_of_pname:Summary.proc_resolve_attributes predicate + Annotations.pname_has_return_annot pn ~attrs_of_pname:Summary.OnDisk.proc_resolve_attributes + predicate let is_functional pname = @@ -342,8 +343,8 @@ let is_thread_safe_class pname tenv = let is_thread_safe_method pname tenv = - find_method_or_override_annotated ~attrs_of_pname:Summary.proc_resolve_attributes is_thread_safe - pname tenv + find_method_or_override_annotated ~attrs_of_pname:Summary.OnDisk.proc_resolve_attributes + is_thread_safe pname tenv |> Option.is_some diff --git a/infer/src/concurrency/starvation.ml b/infer/src/concurrency/starvation.ml index 27d93b660..59d0309cb 100644 --- a/infer/src/concurrency/starvation.ml +++ b/infer/src/concurrency/starvation.ml @@ -159,8 +159,8 @@ let analyze_procedure {Callbacks.exe_env; summary} = StarvationDomain.acquire tenv StarvationDomain.bottom loc (Option.to_list lock) in let initial = - ConcurrencyModels.runs_on_ui_thread ~attrs_of_pname:Summary.proc_resolve_attributes tenv - proc_desc + ConcurrencyModels.runs_on_ui_thread ~attrs_of_pname:Summary.OnDisk.proc_resolve_attributes + tenv proc_desc |> Option.value_map ~default:initial ~f:(StarvationDomain.set_on_ui_thread initial loc) in let filter_blocks = diff --git a/infer/src/nullsafe/NullabilityCheck.ml b/infer/src/nullsafe/NullabilityCheck.ml index 9b071d4f9..553d6357f 100644 --- a/infer/src/nullsafe/NullabilityCheck.ml +++ b/infer/src/nullsafe/NullabilityCheck.ml @@ -41,7 +41,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct ~f:(fun attributes -> ClangMethodKind.equal attributes.ProcAttributes.clang_method_kind ClangMethodKind.CPP_INSTANCE ) - (Summary.proc_resolve_attributes callee_pname) + (Summary.OnDisk.proc_resolve_attributes callee_pname) let is_objc_instance_method callee_pname = @@ -49,7 +49,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct ~f:(fun attributes -> ClangMethodKind.equal attributes.ProcAttributes.clang_method_kind ClangMethodKind.OBJC_INSTANCE ) - (Summary.proc_resolve_attributes callee_pname) + (Summary.OnDisk.proc_resolve_attributes callee_pname) let is_blacklisted_method : Typ.Procname.t -> bool = @@ -91,7 +91,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct let lookup_local_attributes = function | Typ.Procname.Java _ as pname -> (* Looking up the attribute according to the classpath *) - Summary.proc_resolve_attributes pname + Summary.OnDisk.proc_resolve_attributes pname | pname -> (* Looking up the attributes locally, i.e. either from the file of from the includes *) Option.map ~f:Procdesc.get_attributes (Ondemand.get_proc_desc pname) diff --git a/infer/src/nullsafe/typeCheck.ml b/infer/src/nullsafe/typeCheck.ml index c8455f472..fde696115 100644 --- a/infer/src/nullsafe/typeCheck.ml +++ b/infer/src/nullsafe/typeCheck.ml @@ -754,7 +754,7 @@ let typecheck_instr tenv calls_this checks (node : Procdesc.Node.t) idenv curr_p in let resolved_ret_ = let ret_ia, ret_typ = callee_annotated_signature.AnnotatedSignature.ret in - let is_library = Summary.proc_is_library callee_attributes in + let is_library = Summary.OnDisk.proc_is_library callee_attributes in let origin = TypeOrigin.Proc { TypeOrigin.pname= callee_pname diff --git a/infer/src/unit/TaintTests.ml b/infer/src/unit/TaintTests.ml index 7b1c29e63..41d44680e 100644 --- a/infer/src/unit/TaintTests.ml +++ b/infer/src/unit/TaintTests.ml @@ -154,7 +154,7 @@ let tests = ; ( "sink without source not tracked" , [assign_to_non_source "ret_id"; call_sink "ret_id"; assert_empty] ) ] |> TestInterpreter.create_tests ~pp_opt:pp_sparse - {formal_map= FormalMap.empty; summary= Summary.dummy} + {formal_map= FormalMap.empty; summary= Summary.OnDisk.dummy} ~initial:(MockTaintAnalysis.Domain.bottom, Bindings.empty) in "taint_test_suite" >::: test_list diff --git a/infer/src/unit/analyzerTester.ml b/infer/src/unit/analyzerTester.ml index b3bb237d5..c868299d6 100644 --- a/infer/src/unit/analyzerTester.ml +++ b/infer/src/unit/analyzerTester.ml @@ -243,7 +243,7 @@ struct let exit_node = create_node Procdesc.Node.Exit_node [] in set_succs last_node [exit_node] ~exn_handlers:no_exn_handlers ; Procdesc.set_exit_node pdesc exit_node ; - (Summary.reset pdesc, assert_map) + (Summary.OnDisk.reset pdesc, assert_map) let create_test test_program extras ~initial pp_opt test_pname _ =