[backend] Remove AttributesTable.get_tenv

Summary:
Pass the exe_env to checker cluster callbacks, and add it to the domain
extras for BoundedCallTree, and use the Exe_env instead of
AttributesTable to obtain the tenv.

Reviewed By: sblackshear

Differential Revision: D3921850

fbshipit-source-id: 9edf324
master
Josh Berdine 9 years ago committed by Facebook Github Bot 2
parent 32d8036ebe
commit af51599e0f

@ -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. */

@ -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. */

@ -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. *)

@ -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 ->

@ -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

@ -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
| _ ->
()

Loading…
Cancel
Save