diff --git a/infer/src/absint/SummaryPayload.ml b/infer/src/absint/SummaryPayload.ml index b0b5cdc06..9b95c2458 100644 --- a/infer/src/absint/SummaryPayload.ml +++ b/infer/src/absint/SummaryPayload.ml @@ -41,19 +41,21 @@ module Make (P : Payload) : S with type t = P.t = struct let of_summary (summary : Summary.t) = of_payloads summary.payloads - let read_all ?caller_summary ~callee_pname = + let get_payload analysis_result = let open Option.Monad_infix in - Ondemand.analyze_proc_name ?caller_summary callee_pname + analysis_result >>= fun summary -> of_summary summary >>| fun payload -> (Summary.get_proc_desc summary, payload) - let read_full ~caller_summary ~callee_pname = read_all ~caller_summary ~callee_pname + let read_full ~caller_summary ~callee_pname = + Ondemand.analyze_proc_name ~caller_summary callee_pname |> get_payload + let read ~caller_summary ~callee_pname = - read_all ~caller_summary ~callee_pname |> Option.map ~f:snd + Ondemand.analyze_proc_name ~caller_summary callee_pname |> get_payload |> Option.map ~f:snd let read_toplevel_procedure callee_pname = - read_all ?caller_summary:None ~callee_pname |> Option.map ~f:snd + Ondemand.analyze_proc_name_no_caller callee_pname |> get_payload |> Option.map ~f:snd end diff --git a/infer/src/backend/ondemand.ml b/infer/src/backend/ondemand.ml index 71fb4faaf..d2a6f0cb1 100644 --- a/infer/src/backend/ondemand.ml +++ b/infer/src/backend/ondemand.ml @@ -334,12 +334,18 @@ let analyze_proc_desc ~caller_summary callee_pdesc = analyze_proc ~caller_summary callee_pname (Some callee_pdesc) should_be_analyzed -(** analyze_proc_name ?caller_summary callee_pname performs an on-demand analysis of callee_pname triggered +(** analyze_proc_name ~caller_summary callee_pname performs an on-demand analysis of callee_pname triggered during the analysis of caller_summary *) -let analyze_proc_name ?caller_summary callee_pname = +let analyze_proc_name ~caller_summary callee_pname = let should_be_analyzed = procedure_should_be_analyzed callee_pname in let callee_pdesc = get_proc_desc callee_pname in - analyze_proc ?caller_summary callee_pname callee_pdesc should_be_analyzed + analyze_proc ~caller_summary callee_pname callee_pdesc should_be_analyzed + + +let analyze_proc_name_no_caller callee_pname = + let should_be_analyzed = procedure_should_be_analyzed callee_pname in + let callee_pdesc = get_proc_desc callee_pname in + analyze_proc ?caller_summary:None callee_pname callee_pdesc should_be_analyzed let clear_cache () = Typ.Procname.Hash.clear (Lazy.force cached_results) @@ -349,7 +355,9 @@ let analyze_procedures exe_env procs_to_analyze source_file_opt = Option.iter source_file_opt ~f:(fun source_file -> if Config.dump_duplicate_symbols then dump_duplicate_procs source_file procs_to_analyze ) ; set_exe_env exe_env ; - let analyze_proc_name_call pname = ignore (analyze_proc_name pname : Summary.t option) in + let analyze_proc_name_call pname = + ignore (analyze_proc_name_no_caller pname : Summary.t option) + in List.iter ~f:analyze_proc_name_call procs_to_analyze ; Option.iter source_file_opt ~f:(fun source_file -> Callbacks.iterate_cluster_callbacks procs_to_analyze exe_env source_file ; diff --git a/infer/src/backend/ondemand.mli b/infer/src/backend/ondemand.mli index f2e5ea44e..286804fe8 100644 --- a/infer/src/backend/ondemand.mli +++ b/infer/src/backend/ondemand.mli @@ -16,10 +16,14 @@ val analyze_proc_desc : caller_summary:Summary.t -> Procdesc.t -> Summary.t opti (** [analyze_proc_desc ~caller_summary callee_pdesc] performs an on-demand analysis of callee_pdesc triggered during the analysis of caller_summary *) -val analyze_proc_name : ?caller_summary:Summary.t -> Typ.Procname.t -> Summary.t option +val analyze_proc_name : caller_summary:Summary.t -> Typ.Procname.t -> Summary.t option (** [analyze_proc_name ~caller_summary callee_pname] performs an on-demand analysis of callee_pname triggered during the analysis of caller_summary *) +val analyze_proc_name_no_caller : Typ.Procname.t -> Summary.t option +(** [analyze_proc_name_no_caller callee_pname] performs an on-demand analysis of callee_pname + triggered by the top-level of a cluster checker *) + val set_exe_env : Exe_env.t -> unit (** Set the execution enviroment used during on-demand analysis. *)