From 08fb93022f74732438648404332d0bd54f890ed2 Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Thu, 11 Apr 2019 03:54:55 -0700 Subject: [PATCH] [ai] read proc_desc too Summary: This provides a way for AI checkers to read the formals of a procedure, or other things related to its `Procdesc.t`. Reviewed By: mbouaziz Differential Revision: D14258483 fbshipit-source-id: a28e28d3c --- infer/src/absint/SummaryPayload.ml | 16 ++++++++++++++-- infer/src/absint/SummaryPayload.mli | 5 +++++ 2 files changed, 19 insertions(+), 2 deletions(-) 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