[ondemand] kill analyze_proc_desc

Summary: The Ondemand entry point `analyze_proc_desc` exists purely to support specialisation under biabduction. After fixing the storing of specialised `proc_desc`s for java it suffices to use `analyze_proc_name` which will work just fine in its place.

Reviewed By: jvillard

Differential Revision: D25421763

fbshipit-source-id: b162feec3
master
Nikos Gorogiannis 4 years ago committed by Facebook GitHub Bot
parent f4c52851fb
commit 8c4b212545

@ -166,8 +166,5 @@ let with_formals_types callee_pdesc resolved_pname args =
in
let resolved_proc_desc = Procdesc.from_proc_attributes resolved_attributes in
let resolved_proc_desc = with_formals_types_proc callee_pdesc resolved_proc_desc substitutions in
(* The attributes here are used to retrieve the per-file type environment for Clang languages.
The analysis for Java is using a global type environment *)
if not (Procname.is_java resolved_pname) then
Attributes.store ~proc_desc:(Some resolved_proc_desc) resolved_attributes ;
resolved_proc_desc

@ -13,7 +13,6 @@ type 'payload t =
; err_log: Errlog.t
; exe_env: Exe_env.t
; analyze_dependency: Procname.t -> (Procdesc.t * 'payload) option
; analyze_pdesc_dependency: Procdesc.t -> 'payload option
; update_stats: ?add_symops:int -> ?failure_kind:SymOp.failure_kind -> unit -> unit }
type 'payload file_t =
@ -28,8 +27,4 @@ let bind_payload ~f analysis_data =
(fun proc_name ->
analysis_data.analyze_dependency proc_name
|> Option.bind ~f:(fun (proc_desc, payloads) ->
Option.map (f payloads) ~f:(fun payloads' -> (proc_desc, payloads')) ) )
; analyze_pdesc_dependency=
(fun proc_desc ->
analysis_data.analyze_pdesc_dependency proc_desc
|> Option.bind ~f:(fun payloads -> f payloads) ) }
Option.map (f payloads) ~f:(fun payloads' -> (proc_desc, payloads')) ) ) }

@ -20,8 +20,6 @@ type 'payload t =
; analyze_dependency: Procname.t -> (Procdesc.t * 'payload) option
(** On-demand analysis of callees or other dependencies of the analysis of the current
procedure. Uses [Ondemand.analyze_procedure]. *)
; analyze_pdesc_dependency: Procdesc.t -> 'payload option
(** same as above when we already know the {!Procdesc.t} *)
; update_stats: ?add_symops:int -> ?failure_kind:SymOp.failure_kind -> unit -> unit
(** update the [Summary.Stats.t] of the summary of the current procedure *) }

@ -16,17 +16,13 @@ let () =
; proc_resolve_attributes_f= Summary.OnDisk.proc_resolve_attributes }
let mk_interprocedural_t ~f_analyze_dep ~f_analyze_pdesc_dep ~get_payload exe_env summary
let mk_interprocedural_t ~f_analyze_dep ~get_payload exe_env summary
?(tenv = Exe_env.get_tenv exe_env (Summary.get_proc_name summary)) () =
let analyze_dependency proc_name =
let summary = Ondemand.analyze_proc_name exe_env ~caller_summary:summary proc_name in
Option.bind summary ~f:(fun {Summary.payloads; proc_desc; _} ->
f_analyze_dep proc_desc (get_payload payloads) )
in
let analyze_pdesc_dependency proc_desc =
let summary = Ondemand.analyze_proc_desc exe_env ~caller_summary:summary proc_desc in
Option.bind summary ~f:(fun {Summary.payloads; _} -> f_analyze_pdesc_dep (get_payload payloads))
in
let stats = ref summary.Summary.stats in
let update_stats ?add_symops ?failure_kind () =
stats := Summary.Stats.update ?add_symops ?failure_kind !stats
@ -36,7 +32,6 @@ let mk_interprocedural_t ~f_analyze_dep ~f_analyze_pdesc_dep ~get_payload exe_en
; err_log= Summary.get_err_log summary
; exe_env
; analyze_dependency
; analyze_pdesc_dependency
; update_stats }
, stats )
@ -45,13 +40,12 @@ let mk_interprocedural_field_t payload_field exe_env summary =
mk_interprocedural_t
~f_analyze_dep:(fun pdesc payload_opt ->
Option.map payload_opt ~f:(fun payload -> (pdesc, payload)) )
~f_analyze_pdesc_dep:Fn.id ~get_payload:(Field.get payload_field) exe_env summary
~get_payload:(Field.get payload_field) exe_env summary
let interprocedural ~f_analyze_dep ~f_analyze_pdesc_dep ~get_payload ~set_payload checker
{Callbacks.summary; exe_env} =
let interprocedural ~f_analyze_dep ~get_payload ~set_payload checker {Callbacks.summary; exe_env} =
let analysis_data, stats_ref =
mk_interprocedural_t ~f_analyze_dep ~f_analyze_pdesc_dep ~get_payload exe_env summary ()
mk_interprocedural_t ~f_analyze_dep ~get_payload exe_env summary ()
in
let result = checker analysis_data in
{summary with payloads= set_payload summary.payloads result; stats= !stats_ref}

@ -20,7 +20,6 @@ val mk_interprocedural_field_t :
val interprocedural :
f_analyze_dep:(Procdesc.t -> 'payloads_orig -> (Procdesc.t * 'payloads) option)
-> f_analyze_pdesc_dep:('payloads_orig -> 'payloads option)
-> get_payload:(Payloads.t -> 'payloads_orig)
-> set_payload:(Payloads.t -> 'payload_checker -> Payloads.t)
-> ('payloads InterproceduralAnalysis.t -> 'payload_checker)

@ -304,31 +304,7 @@ let get_proc_desc callee_pname =
; lazy (Topl.get_proc_desc callee_pname) ]
type callee = ProcName of Procname.t | ProcDesc of Procdesc.t
let proc_name_of_callee = function
| ProcName proc_name ->
proc_name
| ProcDesc proc_desc ->
Procdesc.get_proc_name proc_desc
let callee_should_be_analyzed = function
| ProcName proc_name ->
procedure_should_be_analyzed proc_name
| ProcDesc proc_desc ->
should_be_analyzed (Procdesc.get_attributes proc_desc)
let get_callee_proc_desc = function
| ProcDesc proc_desc ->
Some proc_desc
| ProcName proc_name ->
get_proc_desc proc_name
let analyze_callee exe_env ?caller_summary callee =
let callee_pname = proc_name_of_callee callee in
let analyze_callee exe_env ?caller_summary callee_pname =
register_callee ?caller_summary callee_pname ;
if is_active callee_pname then None
else
@ -337,8 +313,8 @@ let analyze_callee exe_env ?caller_summary callee =
callee_summary_option
| None ->
let summ_opt =
if callee_should_be_analyzed callee then
match get_callee_proc_desc callee with
if procedure_should_be_analyzed callee_pname then
match get_proc_desc callee_pname with
| Some callee_pdesc ->
RestartScheduler.lock_exn callee_pname ;
let callee_summary =
@ -356,16 +332,12 @@ let analyze_callee exe_env ?caller_summary callee =
summ_opt
let analyze_proc_desc exe_env ~caller_summary callee_pdesc =
analyze_callee exe_env ~caller_summary (ProcDesc callee_pdesc)
let analyze_proc_name exe_env ~caller_summary callee_pname =
analyze_callee exe_env ~caller_summary (ProcName callee_pname)
analyze_callee exe_env ~caller_summary callee_pname
let analyze_proc_name_no_caller exe_env callee_pname =
analyze_callee exe_env ?caller_summary:None (ProcName callee_pname)
analyze_callee exe_env ?caller_summary:None callee_pname
let analyze_procedures exe_env procs_to_analyze source_file_opt =

@ -12,10 +12,6 @@ open! IStd
val get_proc_desc : Procname.t -> Procdesc.t option
(** Find a proc desc for the procedure, perhaps loading it from disk. *)
val analyze_proc_desc : Exe_env.t -> caller_summary:Summary.t -> Procdesc.t -> Summary.t option
(** [analyze_proc_desc exe_env ~caller_summary callee_pdesc] performs an on-demand analysis of
[callee_pdesc] triggered during the analysis of [caller_summary] *)
val analyze_proc_name : Exe_env.t -> caller_summary:Summary.t -> Procname.t -> Summary.t option
(** [analyze_proc_name exe_env ~caller_summary callee_pname] performs an on-demand analysis of
[callee_pname] triggered during the analysis of [caller_summary] *)

@ -30,7 +30,6 @@ let interprocedural2 payload_field1 payload_field2 checker =
Procedure
(CallbackOfChecker.interprocedural
~f_analyze_dep:(fun proc_desc payloads -> Some (proc_desc, payloads))
~f_analyze_pdesc_dep:Option.some
~get_payload:(fun payloads ->
(Field.get payload_field1 payloads, Field.get payload_field2 payloads) )
~set_payload:(fun payloads payload1 -> Field.fset payload_field1 payloads payload1)
@ -42,7 +41,6 @@ let interprocedural3 payload_field1 payload_field2 payload_field3 ~set_payload c
Procedure
(CallbackOfChecker.interprocedural
~f_analyze_dep:(fun proc_desc payloads -> Some (proc_desc, payloads))
~f_analyze_pdesc_dep:Option.some
~get_payload:(fun payloads ->
( Field.get payload_field1 payloads
, Field.get payload_field2 payloads

@ -585,8 +585,7 @@ type resolve_and_analyze_result =
(** Resolve the procedure name and run the analysis of the resolved procedure if not already
analyzed *)
let resolve_and_analyze
{InterproceduralAnalysis.analyze_dependency; analyze_pdesc_dependency; proc_desc; tenv}
let resolve_and_analyze {InterproceduralAnalysis.analyze_dependency; proc_desc; tenv}
~has_clang_model prop args callee_proc_name call_flags : resolve_and_analyze_result =
if has_clang_model then
{resolved_pname= callee_proc_name; resolved_procdesc_opt= None; resolved_summary_opt= None}
@ -612,8 +611,8 @@ let resolve_and_analyze
resolved_args )
in
( resolved_proc_desc_option
, Option.bind resolved_proc_desc_option ~f:(fun pdesc ->
analyze_pdesc_dependency pdesc |> Option.map ~f:(fun summary -> (pdesc, summary)) ) )
, Option.bind resolved_proc_desc_option ~f:(fun _pdesc ->
analyze_dependency resolved_pname ) )
in
let resolved_pname =
resolve_pname ~caller_pdesc:proc_desc tenv prop args callee_proc_name call_flags

Loading…
Cancel
Save