diff --git a/infer/src/backend/callbacks.ml b/infer/src/backend/callbacks.ml index 140af73ee..004b82516 100644 --- a/infer/src/backend/callbacks.ml +++ b/infer/src/backend/callbacks.ml @@ -144,11 +144,7 @@ let iterate_callbacks (exe_env: Exe_env.t) = SourceFiles.proc_names_of_source exe_env.source_file in if Config.dump_duplicate_symbols then dump_duplicate_procs exe_env procs_to_analyze ; - let analyze_proc_name pname = - Option.iter - ~f:(fun pdesc -> ignore (Ondemand.analyze_proc_desc pdesc)) - (Ondemand.get_proc_desc pname) - in + let analyze_proc_name pname = ignore (Ondemand.analyze_proc_name pname : Specs.summary option) in List.iter ~f:analyze_proc_name procs_to_analyze ; (* Invoke cluster callbacks. *) iterate_cluster_callbacks procs_to_analyze exe_env get_proc_desc ; diff --git a/infer/src/backend/ondemand.ml b/infer/src/backend/ondemand.ml index 00fa8b067..31e354c8e 100644 --- a/infer/src/backend/ondemand.ml +++ b/infer/src/backend/ondemand.ml @@ -168,25 +168,29 @@ let run_proc_analysis analyze_proc ~caller_pdesc callee_pdesc = log_error_and_continue exn initial_summary (FKcrash (Exn.to_string exn)) -let analyze_proc_desc ?caller_pdesc callee_pdesc = +let analyze_proc ?caller_pdesc callee_pdesc = + let callbacks = Option.value_exn !callbacks_ref in + Some (run_proc_analysis callbacks.analyze_ondemand ~caller_pdesc callee_pdesc) + + +let analyze_proc_desc ~caller_pdesc callee_pdesc = let callee_pname = Procdesc.get_proc_name callee_pdesc in if is_active callee_pname then None else let cache = Lazy.force cached_results in try Typ.Procname.Hash.find cache callee_pname with Not_found -> let summary_option = - let callbacks = Option.value_exn !callbacks_ref in let proc_attributes = Procdesc.get_attributes callee_pdesc in if should_be_analyzed callee_pname proc_attributes then - Some (run_proc_analysis callbacks.analyze_ondemand ~caller_pdesc callee_pdesc) + analyze_proc ~caller_pdesc callee_pdesc else Specs.get_summary callee_pname in Typ.Procname.Hash.add cache callee_pname summary_option ; summary_option -(** analyze_proc_name curr_pdesc proc_name performs an on-demand analysis of proc_name triggered - during the analysis of curr_pname *) +(** analyze_proc_name ?caller_pdesc proc_name performs an on-demand analysis of proc_name triggered + during the analysis of caller_pdesc *) let analyze_proc_name ?caller_pdesc callee_pname = if is_active callee_pname then None else @@ -197,7 +201,7 @@ let analyze_proc_name ?caller_pdesc callee_pname = if procedure_should_be_analyzed callee_pname then match callbacks.get_proc_desc callee_pname with | Some callee_pdesc -> - analyze_proc_desc ?caller_pdesc callee_pdesc + analyze_proc ?caller_pdesc callee_pdesc | None -> Specs.get_summary callee_pname else Specs.get_summary callee_pname diff --git a/infer/src/backend/ondemand.mli b/infer/src/backend/ondemand.mli index f3e402472..99b2496e2 100644 --- a/infer/src/backend/ondemand.mli +++ b/infer/src/backend/ondemand.mli @@ -20,7 +20,7 @@ type callbacks = {analyze_ondemand: analyze_ondemand; get_proc_desc: get_proc_de val get_proc_desc : get_proc_desc (** Find a proc desc for the procedure, perhaps loading it from disk. *) -val analyze_proc_desc : ?caller_pdesc:Procdesc.t -> Procdesc.t -> Specs.summary option +val analyze_proc_desc : caller_pdesc:Procdesc.t -> Procdesc.t -> Specs.summary option (** [analyze_proc_desc ~caller_pdesc callee_pdesc] performs an on-demand analysis of callee_pdesc triggered during the analysis of caller_pdesc *)