From e58550da1d4d538ff26f8dfd63c7180dc67458d8 Mon Sep 17 00:00:00 2001 From: Josh Berdine Date: Fri, 23 Dec 2016 03:32:20 -0800 Subject: [PATCH] Simplify Exe_env.get_tenv now that optional arg unused Summary: 957b243 removed the last use of `Exe_env.get_tenv ~create:true` Reviewed By: jeremydubreil Differential Revision: D4364521 fbshipit-source-id: 819efee --- infer/src/backend/exe_env.ml | 26 ++++++++++---------------- infer/src/backend/exe_env.mli | 2 +- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/infer/src/backend/exe_env.ml b/infer/src/backend/exe_env.ml index 05b2a3deb..329193a62 100644 --- a/infer/src/backend/exe_env.ml +++ b/infer/src/backend/exe_env.ml @@ -158,24 +158,18 @@ let file_data_to_cfg file_data = file_data.cfg (** return the type environment associated to the procedure *) -let get_tenv ?(create=false) exe_env proc_name : Tenv.t = - let not_found () = - (* ToDo: a tenv should always be found, it should not be necessary to create one here *) - if create then - Tenv.create () - else - failwith ("get_tenv: file_data not found for" ^ Procname.to_string proc_name) in +let get_tenv exe_env proc_name = match get_file_data exe_env proc_name with - | Some file_data -> - begin - match file_data_to_tenv file_data with - | Some tenv -> - tenv - | None -> - not_found () - end + | Some file_data -> ( + match file_data_to_tenv file_data with + | Some tenv -> + tenv + | None -> + failwithf "get_tenv: tenv not found for %a in file %s" + Procname.pp proc_name (DB.filename_to_string file_data.tenv_file) + ) | None -> - not_found () + failwithf "get_tenv: file_data not found for %a" Procname.pp proc_name (** return the cfg associated to the procedure *) let get_cfg exe_env pname = diff --git a/infer/src/backend/exe_env.mli b/infer/src/backend/exe_env.mli index d30fcb97b..2e2b9f3c9 100644 --- a/infer/src/backend/exe_env.mli +++ b/infer/src/backend/exe_env.mli @@ -35,7 +35,7 @@ val get_cg : t -> Cg.t val get_source : t -> Procname.t -> SourceFile.t option (** return the type environment associated to the procedure *) -val get_tenv : ?create:bool -> t -> Procname.t -> Tenv.t +val get_tenv : t -> Procname.t -> Tenv.t (** return the cfg associated to the procedure *) val get_cfg : t -> Procname.t -> Cfg.cfg option