remove the function Sil.get_typ and use Sil.tenv_lookup instead

Summary:
public
The function Sil.get_typ was actually always call with the optional parameter being `Csu.Class`

Reviewed By: sblackshear

Differential Revision: D2786055

fb-gh-sync-id: 4337258
master
jrm 9 years ago committed by facebook-github-bot-5
parent 467fe385be
commit 8325630da1

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

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

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

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

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

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

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

Loading…
Cancel
Save