From 5aa4ee444b3fae9865b5598caec25acf427519af Mon Sep 17 00:00:00 2001 From: Nikos Gorogiannis Date: Tue, 10 Aug 2021 03:11:03 -0700 Subject: [PATCH] [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 --- infer/src/absint/InterproceduralAnalysis.ml | 2 +- infer/src/absint/InterproceduralAnalysis.mli | 2 +- infer/src/backend/CallbackOfChecker.ml | 5 ++--- infer/src/backend/StarvationGlobalAnalysis.ml | 4 +--- infer/src/concurrency/RacerDFileAnalysis.ml | 2 +- infer/src/concurrency/starvation.ml | 8 ++++---- infer/src/concurrency/starvation.mli | 2 +- infer/src/nullsafe/FileLevelAnalysis.ml | 2 +- 8 files changed, 12 insertions(+), 15 deletions(-) diff --git a/infer/src/absint/InterproceduralAnalysis.ml b/infer/src/absint/InterproceduralAnalysis.ml index abcc1d1cb..9b2855cac 100644 --- a/infer/src/absint/InterproceduralAnalysis.ml +++ b/infer/src/absint/InterproceduralAnalysis.ml @@ -19,7 +19,7 @@ type 'payload file_t = { source_file: SourceFile.t ; procedures: Procname.t list ; 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 = { analysis_data with diff --git a/infer/src/absint/InterproceduralAnalysis.mli b/infer/src/absint/InterproceduralAnalysis.mli index 734cf8942..3713a28a0 100644 --- a/infer/src/absint/InterproceduralAnalysis.mli +++ b/infer/src/absint/InterproceduralAnalysis.mli @@ -28,7 +28,7 @@ type 'payload file_t = { source_file: SourceFile.t (** the source file under analysis *) ; 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 *) - ; 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 [procedures] *) } diff --git a/infer/src/backend/CallbackOfChecker.ml b/infer/src/backend/CallbackOfChecker.ml index 59ecea2d8..d68f715b0 100644 --- a/infer/src/backend/CallbackOfChecker.ml +++ b/infer/src/backend/CallbackOfChecker.ml @@ -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 analyze_file_dependency proc_name = - let summary = Ondemand.analyze_proc_name_no_caller exe_env proc_name in - Option.bind summary ~f:(fun {Summary.payloads; proc_desc; _} -> - Field.get payload_field payloads |> Option.map ~f:(fun payload -> (proc_desc, payload)) ) + Ondemand.analyze_proc_name_no_caller exe_env proc_name + |> Option.bind ~f:(fun {Summary.payloads; _} -> Field.get payload_field payloads) in checker {InterproceduralAnalysis.procedures; source_file; file_exe_env= exe_env; analyze_file_dependency} diff --git a/infer/src/backend/StarvationGlobalAnalysis.ml b/infer/src/backend/StarvationGlobalAnalysis.ml index 5b251c673..7ae43c5aa 100644 --- a/infer/src/backend/StarvationGlobalAnalysis.ml +++ b/infer/src/backend/StarvationGlobalAnalysis.ml @@ -72,9 +72,7 @@ let report exe_env work_set = Starvation.report_on_pair ~analyze_ondemand:(fun pname -> Ondemand.analyze_proc_name exe_env ~caller_summary:summary pname - |> Option.bind ~f:(fun summary -> - Option.map summary.Summary.payloads.starvation ~f:(fun starvation -> - (Summary.get_proc_desc summary, starvation) ) ) ) + |> Option.bind ~f:(fun summary -> summary.Summary.payloads.starvation) ) tenv pattrs pair acc in Event.get_acquired_locks pair.elem.event diff --git a/infer/src/concurrency/RacerDFileAnalysis.ml b/infer/src/concurrency/RacerDFileAnalysis.ml index 16e6e56b0..a0222affe 100644 --- a/infer/src/concurrency/RacerDFileAnalysis.ml +++ b/infer/src/concurrency/RacerDFileAnalysis.ml @@ -677,7 +677,7 @@ let aggregate_by_class {InterproceduralAnalysis.procedures; file_exe_env; analyz |> Option.bind ~f:(fun classname -> analyze_file_dependency 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 (fun summaries_opt -> Some ((procname, summary) :: Option.value ~default:[] summaries_opt) ) diff --git a/infer/src/concurrency/starvation.ml b/infer/src/concurrency/starvation.ml index 5894791d4..23fe236a2 100644 --- a/infer/src/concurrency/starvation.ml +++ b/infer/src/concurrency/starvation.ml @@ -631,7 +631,7 @@ let fold_reportable_summaries analyze_ondemand tenv clazz ~init ~f = |> Option.value_map ~default:acc ~f:(fun other_attrs -> if should_report other_attrs then analyze_ondemand mthd - |> Option.map ~f:(fun (_, payload) -> (mthd, payload)) + |> Option.map ~f:(fun payload -> (mthd, payload)) |> Option.fold ~init:acc ~f else acc ) 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} = if Config.starvation_whole_program then IssueLog.empty 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 - (report_on_pair ~analyze_ondemand:analyze_file_dependency tenv proc_desc) + (report_on_pair ~analyze_ondemand:analyze_file_dependency tenv pattrs) payload report_map in let report_procedure report_map procname = @@ -836,7 +836,7 @@ let reporting {InterproceduralAnalysis.procedures; file_exe_env; analyze_file_de report_map | Some attributes -> 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 if should_report attributes then report_on_proc tenv attributes report_map summary else report_map ) diff --git a/infer/src/concurrency/starvation.mli b/infer/src/concurrency/starvation.mli index e1a7b5302..3baef7a2d 100644 --- a/infer/src/concurrency/starvation.mli +++ b/infer/src/concurrency/starvation.mli @@ -23,7 +23,7 @@ module ReportMap : sig end val report_on_pair : - analyze_ondemand:(Procname.t -> (Procdesc.t * StarvationDomain.summary) option) + analyze_ondemand:(Procname.t -> StarvationDomain.summary option) -> Tenv.t -> ProcAttributes.t -> StarvationDomain.CriticalPair.t diff --git a/infer/src/nullsafe/FileLevelAnalysis.ml b/infer/src/nullsafe/FileLevelAnalysis.ml index ff261e846..6d9a615fa 100644 --- a/infer/src/nullsafe/FileLevelAnalysis.ml +++ b/infer/src/nullsafe/FileLevelAnalysis.ml @@ -21,7 +21,7 @@ let get_summaries List.filter_map procedures ~f:(fun procname -> let* class_name = Procname.get_class_type_name procname 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) )