[ondemand] remove pdesc from return of file analysis

Summary: File analysers do not need the preanalysed procdesc. It's cleaner to not return it at all from the callback, so that there is no possibility of confusion between preanalysed and captured.

Reviewed By: jvillard

Differential Revision: D30197168

fbshipit-source-id: 1dabe9752
master
Nikos Gorogiannis 3 years ago committed by Facebook GitHub Bot
parent b1d86abbf0
commit 5aa4ee444b

@ -19,7 +19,7 @@ type 'payload file_t =
{ source_file: SourceFile.t { source_file: SourceFile.t
; procedures: Procname.t list ; procedures: Procname.t list
; file_exe_env: Exe_env.t ; file_exe_env: Exe_env.t
; analyze_file_dependency: Procname.t -> (Procdesc.t * 'payload) option } ; analyze_file_dependency: Procname.t -> 'payload option }
let bind_payload ~f analysis_data = let bind_payload ~f analysis_data =
{ analysis_data with { analysis_data with

@ -28,7 +28,7 @@ type 'payload file_t =
{ source_file: SourceFile.t (** the source file under analysis *) { source_file: SourceFile.t (** the source file under analysis *)
; procedures: Procname.t list (** list of procedures declared in the source file *) ; procedures: Procname.t list (** list of procedures declared in the source file *)
; file_exe_env: Exe_env.t (** {!Exe_env.t} for the current analysis *) ; file_exe_env: Exe_env.t (** {!Exe_env.t} for the current analysis *)
; analyze_file_dependency: Procname.t -> (Procdesc.t * 'payload) option ; analyze_file_dependency: Procname.t -> 'payload option
(** On-demand analysis of dependencies needed for the file analysis, e.g. the proc names in (** On-demand analysis of dependencies needed for the file analysis, e.g. the proc names in
[procedures] *) } [procedures] *) }

@ -58,9 +58,8 @@ let interprocedural_with_field payload_field checker {Callbacks.summary; exe_env
let interprocedural_file payload_field checker {Callbacks.procedures; exe_env; source_file} = let interprocedural_file payload_field checker {Callbacks.procedures; exe_env; source_file} =
let analyze_file_dependency proc_name = let analyze_file_dependency proc_name =
let summary = Ondemand.analyze_proc_name_no_caller exe_env proc_name in Ondemand.analyze_proc_name_no_caller exe_env proc_name
Option.bind summary ~f:(fun {Summary.payloads; proc_desc; _} -> |> Option.bind ~f:(fun {Summary.payloads; _} -> Field.get payload_field payloads)
Field.get payload_field payloads |> Option.map ~f:(fun payload -> (proc_desc, payload)) )
in in
checker checker
{InterproceduralAnalysis.procedures; source_file; file_exe_env= exe_env; analyze_file_dependency} {InterproceduralAnalysis.procedures; source_file; file_exe_env= exe_env; analyze_file_dependency}

@ -72,9 +72,7 @@ let report exe_env work_set =
Starvation.report_on_pair Starvation.report_on_pair
~analyze_ondemand:(fun pname -> ~analyze_ondemand:(fun pname ->
Ondemand.analyze_proc_name exe_env ~caller_summary:summary pname Ondemand.analyze_proc_name exe_env ~caller_summary:summary pname
|> Option.bind ~f:(fun summary -> |> Option.bind ~f:(fun summary -> summary.Summary.payloads.starvation) )
Option.map summary.Summary.payloads.starvation ~f:(fun starvation ->
(Summary.get_proc_desc summary, starvation) ) ) )
tenv pattrs pair acc tenv pattrs pair acc
in in
Event.get_acquired_locks pair.elem.event Event.get_acquired_locks pair.elem.event

@ -677,7 +677,7 @@ let aggregate_by_class {InterproceduralAnalysis.procedures; file_exe_env; analyz
|> Option.bind ~f:(fun classname -> |> Option.bind ~f:(fun classname ->
analyze_file_dependency procname analyze_file_dependency procname
|> Option.filter ~f:(fun _ -> should_report_on_proc file_exe_env procname) |> Option.filter ~f:(fun _ -> should_report_on_proc file_exe_env procname)
|> Option.map ~f:(fun (_, summary) -> |> Option.map ~f:(fun summary ->
Typ.Name.Map.update classname Typ.Name.Map.update classname
(fun summaries_opt -> (fun summaries_opt ->
Some ((procname, summary) :: Option.value ~default:[] summaries_opt) ) Some ((procname, summary) :: Option.value ~default:[] summaries_opt) )

@ -631,7 +631,7 @@ let fold_reportable_summaries analyze_ondemand tenv clazz ~init ~f =
|> Option.value_map ~default:acc ~f:(fun other_attrs -> |> Option.value_map ~default:acc ~f:(fun other_attrs ->
if should_report other_attrs then if should_report other_attrs then
analyze_ondemand mthd analyze_ondemand mthd
|> Option.map ~f:(fun (_, payload) -> (mthd, payload)) |> Option.map ~f:(fun payload -> (mthd, payload))
|> Option.fold ~init:acc ~f |> Option.fold ~init:acc ~f
else acc ) else acc )
in in
@ -825,9 +825,9 @@ let report_on_pair ~analyze_ondemand tenv pattrs (pair : Domain.CriticalPair.t)
let reporting {InterproceduralAnalysis.procedures; file_exe_env; analyze_file_dependency} = let reporting {InterproceduralAnalysis.procedures; file_exe_env; analyze_file_dependency} =
if Config.starvation_whole_program then IssueLog.empty if Config.starvation_whole_program then IssueLog.empty
else else
let report_on_proc tenv proc_desc report_map payload = let report_on_proc tenv pattrs report_map payload =
Domain.fold_critical_pairs_of_summary Domain.fold_critical_pairs_of_summary
(report_on_pair ~analyze_ondemand:analyze_file_dependency tenv proc_desc) (report_on_pair ~analyze_ondemand:analyze_file_dependency tenv pattrs)
payload report_map payload report_map
in in
let report_procedure report_map procname = let report_procedure report_map procname =
@ -836,7 +836,7 @@ let reporting {InterproceduralAnalysis.procedures; file_exe_env; analyze_file_de
report_map report_map
| Some attributes -> | Some attributes ->
analyze_file_dependency procname analyze_file_dependency procname
|> Option.value_map ~default:report_map ~f:(fun (_proc_desc, summary) -> |> Option.value_map ~default:report_map ~f:(fun summary ->
let tenv = Exe_env.get_proc_tenv file_exe_env procname in let tenv = Exe_env.get_proc_tenv file_exe_env procname in
if should_report attributes then report_on_proc tenv attributes report_map summary if should_report attributes then report_on_proc tenv attributes report_map summary
else report_map ) else report_map )

@ -23,7 +23,7 @@ module ReportMap : sig
end end
val report_on_pair : val report_on_pair :
analyze_ondemand:(Procname.t -> (Procdesc.t * StarvationDomain.summary) option) analyze_ondemand:(Procname.t -> StarvationDomain.summary option)
-> Tenv.t -> Tenv.t
-> ProcAttributes.t -> ProcAttributes.t
-> StarvationDomain.CriticalPair.t -> StarvationDomain.CriticalPair.t

@ -21,7 +21,7 @@ let get_summaries
List.filter_map procedures ~f:(fun procname -> List.filter_map procedures ~f:(fun procname ->
let* class_name = Procname.get_class_type_name procname in let* class_name = Procname.get_class_type_name procname in
let* java_class_name = get_java_class_name class_name in let* java_class_name = get_java_class_name class_name in
let* _proc_desc, summary = analyze_file_dependency procname in let* summary = analyze_file_dependency procname in
return (java_class_name, summary) ) return (java_class_name, summary) )

Loading…
Cancel
Save