diff --git a/infer/src/backend/sil.ml b/infer/src/backend/sil.ml index 51238c0d6..777f6a3c7 100644 --- a/infer/src/backend/sil.ml +++ b/infer/src/backend/sil.ml @@ -3746,13 +3746,6 @@ let tenv_lookup tenv name = let tenv_add tenv name typ = TypenameHash.replace tenv name typ -(** look up the type for a mangled name in the current type environment *) -let get_typ name csu_option tenv = - let csu = match csu_option with - | Some t -> t - | None -> Csu.Class in - tenv_lookup tenv (Typename.TN_csu (csu, name)) - (** expand a type if it is a typename by looking it up in the type environment *) let rec expand_type tenv typ = match typ with diff --git a/infer/src/backend/sil.mli b/infer/src/backend/sil.mli index 9136f610d..0f03fe10f 100644 --- a/infer/src/backend/sil.mli +++ b/infer/src/backend/sil.mli @@ -513,9 +513,6 @@ val tenv_lookup : tenv -> Typename.t -> typ option (** Add a (name,typ) pair to the global type environment. *) val tenv_add : tenv -> Typename.t -> typ -> unit -(** look up the type for a mangled name in the current type environment *) -val get_typ : Mangled.t -> Csu.t option -> tenv -> typ option - (** expand a type if it is a typename by looking it up in the type environment *) val expand_type : tenv -> typ -> typ diff --git a/infer/src/checkers/callbackChecker.ml b/infer/src/checkers/callbackChecker.ml index 7b8215a8d..27ac19ea6 100644 --- a/infer/src/checkers/callbackChecker.ml +++ b/infer/src/checkers/callbackChecker.ml @@ -80,7 +80,9 @@ let do_eradicate_check all_procs get_procdesc idenv tenv = * [procname]. in addition, if [procname] is a special "destroy" /"cleanup" method, save the set of * fields that are nullified *) let callback_checker_main all_procs get_procdesc idenv tenv proc_name proc_desc = - match Sil.get_typ (Mangled.from_string (Procname.java_get_class proc_name)) None tenv with + let typename = + Typename.TN_csu (Csu.Class, Mangled.from_string (Procname.java_get_class proc_name)) in + match Sil.tenv_lookup tenv typename with | Some (Sil.Tstruct(_, _, csu, Some class_name, _, methods, _) as typ) -> let lifecycle_typs = get_or_create_lifecycle_typs tenv in let proc_belongs_to_lifecycle_typ = IList.exists diff --git a/infer/src/checkers/patternMatch.ml b/infer/src/checkers/patternMatch.ml index f2a1084b3..8de8f3e4d 100644 --- a/infer/src/checkers/patternMatch.ml +++ b/infer/src/checkers/patternMatch.ml @@ -81,7 +81,7 @@ let type_find_supertype | Some c -> c = csu | None -> true in let has_indirect_supertype () = - match Sil.get_typ m csu_opt tenv with + match Sil.tenv_lookup tenv (Typename.TN_csu (Csu.Class, m)) with | Some supertype -> has_supertype supertype (Sil.TypSet.add typ visited) | None -> false in (match_csu () && match_name () diff --git a/infer/src/checkers/performanceCritical.ml b/infer/src/checkers/performanceCritical.ml index a206068f5..88d43f4dc 100644 --- a/infer/src/checkers/performanceCritical.ml +++ b/infer/src/checkers/performanceCritical.ml @@ -79,7 +79,7 @@ let is_modeled_expensive tenv pname = | Some p -> p in let classname = Mangled.from_package_class package (Procname.java_get_simple_class pname) in - match Sil.get_typ classname (Some Csu.Class) tenv with + match Sil.tenv_lookup tenv (Typename.TN_csu (Csu.Class, classname)) with | None -> false | Some typ -> AndroidFramework.is_view typ tenv diff --git a/infer/src/harness/androidFramework.ml b/infer/src/harness/androidFramework.ml index f6ddda18e..9001a79dc 100644 --- a/infer/src/harness/androidFramework.ml +++ b/infer/src/harness/androidFramework.ml @@ -255,7 +255,9 @@ let get_all_supertypes typ tenv = let get_direct_supers = function | Sil.Tstruct (_, _, Csu.Class, _, supers, _, _) -> supers | _ -> [] in - let rec add_typ name typs = match Sil.get_typ name None tenv with + let rec add_typ name typs = + let typename = Typename.TN_csu (Csu.Class, name) in + match Sil.tenv_lookup tenv typename with | Some typ -> get_supers_rec typ tenv (TypSet.add typ typs) | None -> typs and get_supers_rec typ tenv all_supers = @@ -269,7 +271,7 @@ let is_subtype (typ0 : Sil.typ) (typ1 : Sil.typ) tenv = let is_subtype_package_class typ package classname tenv = let classname = Mangled.from_package_class package classname in - match Sil.get_typ classname (Some Csu.Class) tenv with + match Sil.tenv_lookup tenv (Typename.TN_csu (Csu.Class, classname)) with | Some found_typ -> is_subtype typ found_typ tenv | _ -> false @@ -352,7 +354,7 @@ let is_callback_register_method procname args tenv = (** given an Android framework type mangled string [lifecycle_typ] (e.g., android.app.Activity) and a list of method names [lifecycle_procs_strs], get the appropriate typ and procnames *) let get_lifecycle_for_framework_typ_opt lifecycle_typ lifecycle_proc_strs tenv = - match Sil.get_typ lifecycle_typ None tenv with + match Sil.tenv_lookup tenv (Typename.TN_csu (Csu.Class, lifecycle_typ)) with | Some (Sil.Tstruct(_, _, Csu.Class, Some class_name, _, decl_procs, _) as lifecycle_typ) -> (* TODO (t4645631): collect the procedures for which is_java is returning false *) let lookup_proc lifecycle_proc = diff --git a/infer/src/harness/inhabit.ml b/infer/src/harness/inhabit.ml index 7c7417866..5befccd3d 100644 --- a/infer/src/harness/inhabit.ml +++ b/infer/src/harness/inhabit.ml @@ -269,7 +269,8 @@ let add_harness_to_cg harness_name harness_cfg harness_node loc cg tenv = Sil.Tptr (Sil.Tarray (lookup_typ stripped_typ, array_typ_size), Sil.Pk_pointer) | _ -> (* non-primitive/non-array type--resolve it in the tenv *) - match Sil.get_typ (Mangled.from_string typ_str) None tenv with + let typename = Typename.TN_csu (Csu.Class, (Mangled.from_string typ_str)) in + match Sil.tenv_lookup tenv typename with | Some typ -> typ | None -> failwith ("Failed to look up typ " ^ typ_str) in let ret_type = lookup_typ (Procname.java_get_return_type proc_name) in