From db285f976ccee3ecd6dec6d9d879b36c5b10e042 Mon Sep 17 00:00:00 2001 From: Jeremy Dubreil Date: Thu, 16 Feb 2017 09:51:20 -0800 Subject: [PATCH] [infer][java] avoid redundant calls to the function procedure_should_be_analyzed for Infer.SL Summary: This simplifies a bit the code to run the analysis on all the prcedures in the cluster. Before, the functions procedure_should_be_analyzed, which loads the attributes, and get_proc_desc were called twice for the analysis of every procedure. The objective is to remove the calls to procedure_should_be_analyzed and hide it from the ondemand API since it is already called before the analysis of every procedure. Reviewed By: sblackshear Differential Revision: D4553397 fbshipit-source-id: 02cffaf --- infer/src/backend/interproc.ml | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/infer/src/backend/interproc.ml b/infer/src/backend/interproc.ml index be896698f..b89a4d53e 100644 --- a/infer/src/backend/interproc.ml +++ b/infer/src/backend/interproc.ml @@ -1403,27 +1403,18 @@ let interprocedural_algorithm exe_env : unit = Int.equal (Specs.get_timestamp summary) 0 in let procs_to_analyze = List.filter ~f:filter_initial (Cg.get_defined_nodes call_graph) in - let to_analyze proc_name = - match Exe_env.get_proc_desc exe_env proc_name with - | Some proc_desc -> - let reactive_changed = - if Config.reactive_mode - then (Procdesc.get_attributes proc_desc).ProcAttributes.changed - else true in - if - reactive_changed && (* in reactive mode, only analyze changed procedures *) - Ondemand.procedure_should_be_analyzed proc_name - then - Some proc_desc - else - None - | None -> - None in let process_one_proc proc_name = - match to_analyze proc_name with - | Some pdesc -> Ondemand.analyze_proc_name ~propagate_exceptions:false pdesc proc_name + let analyze proc_desc = + Ondemand.analyze_proc_desc ~propagate_exceptions:false proc_desc proc_desc in + match Exe_env.get_proc_desc exe_env proc_name with + | Some proc_desc + when Config.reactive_mode (* in reactive mode, only analyze changed procedures *) + && (Procdesc.get_attributes proc_desc).ProcAttributes.changed -> + analyze proc_desc + | Some proc_desc -> analyze proc_desc | None -> () in - IList.iter process_one_proc procs_to_analyze + List.iter ~f:process_one_proc procs_to_analyze + (** Perform the analysis of an exe_env *) let do_analysis exe_env =