diff --git a/infer/src/absint/SummaryPayload.ml b/infer/src/absint/SummaryPayload.ml index 1c05b52ca..d80f484d1 100644 --- a/infer/src/absint/SummaryPayload.ml +++ b/infer/src/absint/SummaryPayload.ml @@ -22,6 +22,8 @@ module type S = sig val of_summary : Summary.t -> t option + val read_full : Procdesc.t -> Typ.Procname.t -> (Procdesc.t * t) option + val read : Procdesc.t -> Typ.Procname.t -> t option end @@ -34,6 +36,16 @@ module Make (P : Payload) : S with type t = P.t = struct let of_summary (summary : Summary.t) = P.of_payloads summary.payloads - let read caller_pdesc callee_pname = - Ondemand.analyze_proc_name ~caller_pdesc callee_pname |> Option.bind ~f:of_summary + let read_full caller_pdesc callee_pname = + let open Option.Monad_infix in + Ondemand.analyze_proc_name ~caller_pdesc callee_pname + >>= fun summary -> + of_summary summary + >>| fun payload -> + (* we could return the proc_desc if some client needed this but this would complicate the return + type so for now let's not do that *) + (Summary.get_proc_desc summary, payload) + + + let read caller_pdesc callee_pname = read_full caller_pdesc callee_pname |> Option.map ~f:snd end diff --git a/infer/src/absint/SummaryPayload.mli b/infer/src/absint/SummaryPayload.mli index ba877195b..4be1467a1 100644 --- a/infer/src/absint/SummaryPayload.mli +++ b/infer/src/absint/SummaryPayload.mli @@ -26,6 +26,11 @@ module type S = sig val of_summary : Summary.t -> t option (** Read the corresponding part of the payload from the procedure summary *) + val read_full : Procdesc.t -> Typ.Procname.t -> (Procdesc.t * t) option + [@@warning "-32"] + (** Return the proc desc and payload for the given procedure. Runs the analysis on-demand if + necessary. *) + val read : Procdesc.t -> Typ.Procname.t -> t option (** Return the payload for the given procedure. Runs the analysis on-demand if necessary. *) end