diff --git a/infer/src/backend/callbacks.ml b/infer/src/backend/callbacks.ml index 96bee1902..543b2994c 100644 --- a/infer/src/backend/callbacks.ml +++ b/infer/src/backend/callbacks.ml @@ -15,7 +15,7 @@ type proc_callback_args = type proc_callback_t = proc_callback_args -> Summary.t type cluster_callback_args = - {procedures: Summary.t list; source_file: SourceFile.t; exe_env: Exe_env.t} + {procedures: Procname.t list; source_file: SourceFile.t; exe_env: Exe_env.t} type cluster_callback_t = cluster_callback_args -> unit @@ -37,10 +37,6 @@ let register_cluster_callback ~name language (callback : cluster_callback_t) = cluster_callbacks := {name; language; callback} :: !cluster_callbacks -let get_procedure_definition proc_name = - Procdesc.load proc_name |> Option.map ~f:Summary.OnDisk.reset - - (** Invoke all registered procedure callbacks on the given procedure. *) let iterate_procedure_callbacks exe_env summary = let proc_desc = Summary.get_proc_desc summary in @@ -74,14 +70,13 @@ let iterate_procedure_callbacks exe_env summary = (** Invoke all registered cluster callbacks on a cluster of procedures. *) -let iterate_cluster_callbacks all_procs exe_env source_file = +let iterate_cluster_callbacks procedures exe_env source_file = if !cluster_callbacks <> [] then - let procedures = List.filter_map ~f:get_procedure_definition all_procs in let environment = {procedures; source_file; exe_env} in let language_matches language = match procedures with - | summary :: _ -> - Language.equal language (Procname.get_language (Summary.get_proc_name summary)) + | procname :: _ -> + Language.equal language (Procname.get_language procname) | _ -> true in diff --git a/infer/src/backend/callbacks.mli b/infer/src/backend/callbacks.mli index 1f4a36f5a..4a9e28374 100644 --- a/infer/src/backend/callbacks.mli +++ b/infer/src/backend/callbacks.mli @@ -21,7 +21,7 @@ type proc_callback_args = type proc_callback_t = proc_callback_args -> Summary.t type cluster_callback_args = - {procedures: Summary.t list; source_file: SourceFile.t; exe_env: Exe_env.t} + {procedures: Procname.t list; source_file: SourceFile.t; exe_env: Exe_env.t} type cluster_callback_t = cluster_callback_args -> unit diff --git a/infer/src/concurrency/RacerD.ml b/infer/src/concurrency/RacerD.ml index c05a16225..9c1f985a2 100644 --- a/infer/src/concurrency/RacerD.ml +++ b/infer/src/concurrency/RacerD.ml @@ -1110,15 +1110,16 @@ let make_results_table exe_env summaries = (* aggregate all of the procedures in the file env by their declaring class. this lets us analyze each class individually *) let aggregate_by_class exe_env file_env = - List.fold file_env ~init:String.Map.empty ~f:(fun acc summary -> - let pdesc = Summary.get_proc_desc summary in - let procname = Summary.get_proc_name summary in - let tenv = Exe_env.get_tenv exe_env procname in - if should_report_on_proc tenv pdesc then - Procdesc.get_proc_name pdesc |> Procname.get_class_name - |> Option.fold ~init:acc ~f:(fun acc classname -> - String.Map.add_multi acc ~key:classname ~data:summary ) - else acc ) + List.fold file_env ~init:String.Map.empty ~f:(fun acc procname -> + Ondemand.analyze_proc_name_no_caller procname + |> Option.value_map ~default:acc ~f:(fun summary -> + let pdesc = Summary.get_proc_desc summary in + let tenv = Exe_env.get_tenv exe_env procname in + if should_report_on_proc tenv pdesc then + Procdesc.get_proc_name pdesc |> Procname.get_class_name + |> Option.fold ~init:acc ~f:(fun acc classname -> + String.Map.add_multi acc ~key:classname ~data:summary ) + else acc ) ) (* Gathers results by analyzing all the methods in a file, then diff --git a/infer/src/concurrency/starvation.ml b/infer/src/concurrency/starvation.ml index 8969e79d9..cf8c5915b 100644 --- a/infer/src/concurrency/starvation.ml +++ b/infer/src/concurrency/starvation.ml @@ -732,14 +732,15 @@ let reporting {Callbacks.procedures; exe_env} = let report_on_summary tenv summary report_map (payload : Domain.summary) = Domain.CriticalPairs.fold (report_on_pair tenv summary) payload.critical_pairs report_map in - let report_procedure report_map summary = - let proc_desc = Summary.get_proc_desc summary in - let procname = Summary.get_proc_name summary in - let tenv = Exe_env.get_tenv exe_env procname in - if should_report proc_desc then - Payload.read_toplevel_procedure procname - |> Option.fold ~init:report_map ~f:(report_on_summary tenv summary) - else report_map + let report_procedure report_map procname = + Ondemand.analyze_proc_name_no_caller procname + |> Option.value_map ~default:report_map ~f:(fun summary -> + let proc_desc = Summary.get_proc_desc summary in + let tenv = Exe_env.get_tenv exe_env procname in + if should_report proc_desc then + Payload.read_toplevel_procedure procname + |> Option.fold ~init:report_map ~f:(report_on_summary tenv summary) + else report_map ) in List.fold procedures ~init:ReportMap.empty ~f:report_procedure |> ReportMap.store