[infer][ondemand] cache the results of the on-demand analysis

Summary: For the Buck integration for Java, caching when a summary is not found avoids going through the whole classpath every time a summary for the same method is not found.

Reviewed By: mbouaziz, jvillard

Differential Revision: D6402833

fbshipit-source-id: 4feb422
master
Jeremy Dubreil 7 years ago committed by Facebook Github Bot
parent 1d0b6050a6
commit e622e7b431

@ -183,7 +183,11 @@ let analyze_proc_desc curr_pdesc callee_pdesc : Specs.summary option =
(** analyze_proc_name curr_pdesc proc_name performs an on-demand analysis of proc_name triggered
during the analysis of curr_pname *)
let analyze_proc_name curr_pdesc callee_pname : Specs.summary option =
let analyze_proc_name : Procdesc.t -> Typ.Procname.t -> Specs.summary option =
let cached_results = Typ.Procname.Hash.create 100 in
fun curr_pdesc callee_pname ->
try Typ.Procname.Hash.find cached_results callee_pname with Not_found ->
let summary_option =
match !callbacks_ref with
| None ->
L.(die InternalError)
@ -198,6 +202,10 @@ let analyze_proc_name curr_pdesc callee_pname : Specs.summary option =
| None ->
Specs.get_summary callee_pname
else Specs.get_summary callee_pname
in
if not (is_active callee_pname) then
Typ.Procname.Hash.add cached_results callee_pname summary_option ;
summary_option
(** Find a proc desc for the procedure, perhaps loading it from disk. *)

Loading…
Cancel
Save