diff --git a/infer/src/IR/AttributesTable.re b/infer/src/IR/AttributesTable.re index b6d84797e..81749d267 100644 --- a/infer/src/IR/AttributesTable.re +++ b/infer/src/IR/AttributesTable.re @@ -80,30 +80,6 @@ let load_attributes proc_name => }; -/** Given a procedure name, find the file where it is defined and its corresponding type - environment */ -let find_tenv_from_class_of_proc procname => - switch (load_attributes procname) { - | None => None - | Some attrs => - let source_file = attrs.ProcAttributes.loc.Location.file; - let source_dir = DB.source_dir_from_source_file source_file; - let tenv_fname = DB.source_dir_get_internal_file source_dir ".tenv"; - Tenv.load_from_file tenv_fname - }; - - -/** Given a procedure name, find the file where it is defined and its corresponding type - environment, or create an empty tenv if necessary. */ -let get_tenv proc_name => - switch (find_tenv_from_class_of_proc proc_name) { - | Some tenv => tenv - /* ToDo: a tenv should always be found, it should not be necessary to create one here */ - | None => Tenv.create () - | exception _ => Tenv.create () - }; - - /** Given the name of an ObjC class, extract the type from the tenv where the class was defined. We do this by adding a method that is unique to each class, and then finding the tenv that corresponds to the class definition. */ diff --git a/infer/src/IR/AttributesTable.rei b/infer/src/IR/AttributesTable.rei index f5371f470..016bd56ed 100644 --- a/infer/src/IR/AttributesTable.rei +++ b/infer/src/IR/AttributesTable.rei @@ -22,16 +22,6 @@ let store_attributes: ProcAttributes.t => unit; let load_attributes: Procname.t => option ProcAttributes.t; -/** Given a procedure name, find the file where it is defined and its corresponding type - environment */ -let find_tenv_from_class_of_proc: Procname.t => option Tenv.t; - - -/** Given a procedure name, find the file where it is defined and its corresponding type - environment, or create an empty tenv if necessary. */ -let get_tenv: Procname.t => Tenv.t; - - /** Given the name of an ObjC class, extract the type from the tenv where the class was defined. We do this by adding a method that is unique to each class, and then finding the tenv that corresponds to the class definition. */ diff --git a/infer/src/backend/callbacks.ml b/infer/src/backend/callbacks.ml index e17aa3943..57a36fe8a 100644 --- a/infer/src/backend/callbacks.ml +++ b/infer/src/backend/callbacks.ml @@ -25,6 +25,7 @@ type proc_callback_args = { type proc_callback_t = proc_callback_args -> unit type cluster_callback_t = + Exe_env.t -> Procname.t list -> (Procname.t -> Cfg.Procdesc.t option) -> (Idenv.t * Tenv.t * Procname.t * Cfg.Procdesc.t) list -> @@ -129,7 +130,7 @@ let iterate_cluster_callbacks all_procs exe_env proc_names = (fun (language_opt, cluster_callback) -> let proc_names = relevant_procedures language_opt in if IList.length proc_names > 0 then - cluster_callback all_procs get_procdesc environment) + cluster_callback exe_env all_procs get_procdesc environment) !cluster_callbacks (** Invoke all procedure and cluster callbacks on a given environment. *) diff --git a/infer/src/backend/callbacks.mli b/infer/src/backend/callbacks.mli index d2e0627ec..01f28e93e 100644 --- a/infer/src/backend/callbacks.mli +++ b/infer/src/backend/callbacks.mli @@ -29,6 +29,7 @@ type proc_callback_args = { type proc_callback_t = proc_callback_args -> unit type cluster_callback_t = + Exe_env.t -> Procname.t list -> (Procname.t -> Cfg.Procdesc.t option) -> (Idenv.t * Tenv.t * Procname.t * Cfg.Procdesc.t) list -> diff --git a/infer/src/checkers/BoundedCallTree.ml b/infer/src/checkers/BoundedCallTree.ml index 1a25acbfb..745ee04c5 100644 --- a/infer/src/checkers/BoundedCallTree.ml +++ b/infer/src/checkers/BoundedCallTree.ml @@ -77,11 +77,10 @@ module TransferFunctions (CFG : ProcCfg.S) = struct module Domain = Domain type extras = extras_t - let stacktree_of_astate pdesc astate loc location_type get_proc_desc = + let stacktree_of_astate tenv pdesc astate loc location_type get_proc_desc = let procs = Domain.elements astate in let callees = IList.map (fun pn -> - let tenv = AttributesTable.get_tenv pn in match SpecSummary.read_summary tenv pdesc pn with | None | Some None -> (match get_proc_desc pn with | None -> stacktree_stub_of_procname pn @@ -95,10 +94,10 @@ module TransferFunctions (CFG : ProcCfg.S) = struct procs in stacktree_of_pdesc pdesc ~loc ~callees location_type - let output_json_summary pdesc astate loc location_type get_proc_desc = + let output_json_summary tenv pdesc astate loc location_type get_proc_desc = let caller = Cfg.Procdesc.get_proc_name pdesc in let stacktree = - stacktree_of_astate pdesc astate loc location_type get_proc_desc in + stacktree_of_astate tenv pdesc astate loc location_type get_proc_desc in let dir = Filename.concat Config.results_dir "crashcontext" in let suffix = F.sprintf "%s_%d" location_type loc.Location.line in let fname = F.sprintf "%s.%s.json" @@ -112,6 +111,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct | Sil.Call (_, Const (Const.Cfun pn), _, loc, _) -> let get_proc_desc = proc_data.ProcData.extras.get_proc_desc in let traces = proc_data.ProcData.extras.stacktraces in + let tenv = proc_data.ProcData.tenv in let caller = Cfg.Procdesc.get_proc_name proc_data.ProcData.pdesc in let matches_proc frame = let matches_class pname = match pname with @@ -136,7 +136,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct let new_astate = Domain.add pn astate in if Stacktrace.frame_matches_location frame loc then begin let pdesc = proc_data.ProcData.pdesc in - output_json_summary pdesc new_astate loc "call_site" get_proc_desc + output_json_summary tenv pdesc new_astate loc "call_site" get_proc_desc end; new_astate with diff --git a/infer/src/checkers/checkers.ml b/infer/src/checkers/checkers.ml index f52a60907..f5a8a36bf 100644 --- a/infer/src/checkers/checkers.ml +++ b/infer/src/checkers/checkers.ml @@ -187,11 +187,11 @@ let callback_check_access { Callbacks.tenv; proc_desc } = Cfg.Procdesc.iter_instrs (report_calls_and_accesses tenv "PROC") proc_desc (** Report all field accesses and method calls of a class. *) -let callback_check_cluster_access all_procs get_proc_desc _ = +let callback_check_cluster_access exe_env all_procs get_proc_desc _ = IList.iter (fun proc_name -> match get_proc_desc proc_name with | Some proc_desc -> - let tenv = AttributesTable.get_tenv proc_name in + let tenv = Exe_env.get_tenv exe_env proc_name in Cfg.Procdesc.iter_instrs (report_calls_and_accesses tenv "CLUSTER") proc_desc | _ -> ()