From 878bf938eb2b22d624060abda215d8c2db34972a Mon Sep 17 00:00:00 2001 From: Sam Blackshear Date: Mon, 29 Feb 2016 08:27:01 -0800 Subject: [PATCH] kill Tenum Reviewed By: cristianoc Differential Revision: D2988278 fb-gh-sync-id: bf26d02 shipit-source-id: bf26d02 --- infer/src/backend/abs.ml | 4 ++-- infer/src/backend/autounit.ml | 2 +- infer/src/backend/prop.ml | 6 +----- infer/src/backend/rearrange.ml | 2 +- infer/src/backend/sil.ml | 16 ---------------- infer/src/backend/sil.mli | 1 - infer/src/clang/cTypes.ml | 16 ---------------- infer/src/clang/cTypes.mli | 2 -- 8 files changed, 5 insertions(+), 44 deletions(-) diff --git a/infer/src/backend/abs.ml b/infer/src/backend/abs.ml index 4a56381db..68c029b80 100644 --- a/infer/src/backend/abs.ml +++ b/infer/src/backend/abs.ml @@ -414,13 +414,13 @@ let typ_get_recursive_flds tenv typ_exp = t | Some typ' -> typ' in Sil.typ_equal typ' typ - | Sil.Tptr _ | Sil.Tstruct _ | Sil.Tarray _ | Sil.Tenum _ -> + | Sil.Tptr _ | Sil.Tstruct _ | Sil.Tarray _ -> false in match typ_exp with | Sil.Sizeof (typ, _) -> (match Sil.expand_type tenv typ with - | Sil.Tint _ | Sil.Tvoid | Sil.Tfun _ | Sil.Tptr _ | Sil.Tfloat _ | Sil.Tenum _ -> [] + | Sil.Tint _ | Sil.Tvoid | Sil.Tfun _ | Sil.Tptr _ | Sil.Tfloat _ -> [] | Sil.Tstruct { Sil.instance_fields } -> IList.map (fun (x, _, _) -> x) (IList.filter (filter typ) instance_fields) | Sil.Tarray _ -> [] diff --git a/infer/src/backend/autounit.ml b/infer/src/backend/autounit.ml index d811bdc7b..867ed18a0 100644 --- a/infer/src/backend/autounit.ml +++ b/infer/src/backend/autounit.ml @@ -414,7 +414,7 @@ let mk_size_name id = let pp_texp_for_malloc fmt = let rec handle_arr_size typ = match typ with - | Sil.Tvar _ | Sil.Tint _ | Sil.Tfloat _ | Sil.Tvoid | Sil.Tfun _ | Sil.Tenum _ -> + | Sil.Tvar _ | Sil.Tint _ | Sil.Tfloat _ | Sil.Tvoid | Sil.Tfun _ -> typ | Sil.Tptr (t, pk) -> Sil.Tptr (handle_arr_size t, pk) diff --git a/infer/src/backend/prop.ml b/infer/src/backend/prop.ml index eed8ae059..da1fd92ed 100644 --- a/infer/src/backend/prop.ml +++ b/infer/src/backend/prop.ml @@ -841,8 +841,6 @@ and typ_normalize sub typ = match typ with } | Sil.Tarray (t, e) -> Sil.Tarray (typ_normalize sub t, exp_normalize sub e) - | Sil.Tenum _ -> - typ let run_with_abs_val_eq_zero f = let abs_val_old = !Config.abs_val in @@ -1092,7 +1090,7 @@ let rec create_strexp_of_type tenvo struct_init_mode typ inst = else create_fresh_var () in match typ with - | Sil.Tint _ | Sil.Tfloat _ | Sil.Tvoid | Sil.Tfun _ | Sil.Tptr _ | Sil.Tenum _ -> + | Sil.Tint _ | Sil.Tfloat _ | Sil.Tvoid | Sil.Tfun _ | Sil.Tptr _ -> Sil.Eexp (init_value (), inst) | Sil.Tstruct { Sil.instance_fields } -> begin @@ -2253,8 +2251,6 @@ and typ_captured_ren ren typ = match typ with Sil.Tptr (typ_captured_ren ren t', pk) | Sil.Tarray (t, e) -> Sil.Tarray (typ_captured_ren ren t, exp_captured_ren ren e) - | Sil.Tenum _ -> - typ let atom_captured_ren ren = function | Sil.Aeq (e1, e2) -> diff --git a/infer/src/backend/rearrange.ml b/infer/src/backend/rearrange.ml index d6f091df8..a5f201336 100644 --- a/infer/src/backend/rearrange.ml +++ b/infer/src/backend/rearrange.ml @@ -161,7 +161,7 @@ let rec create_struct_values pname tenv orig_prop footprint_part kind max_stamp L.d_str "create_struct_values type:"; Sil.d_typ_full t; L.d_str " off: "; Sil.d_offset_list off; L.d_ln(); raise (Exceptions.Bad_footprint __POS__) - | Sil.Tvar _, _ | Sil.Tenum _, _ -> + | Sil.Tvar _, _ -> L.d_str "create_struct_values type:"; Sil.d_typ_full t; L.d_str " off: "; Sil.d_offset_list off; L.d_ln(); assert false in diff --git a/infer/src/backend/sil.ml b/infer/src/backend/sil.ml index e07dc695d..f04ab3cd5 100644 --- a/infer/src/backend/sil.ml +++ b/infer/src/backend/sil.ml @@ -671,7 +671,6 @@ and typ = | Tptr of typ * ptr_kind (** pointer type *) | Tstruct of struct_typ (** Type for a structured value *) | Tarray of typ * exp (** array type with fixed size *) - | Tenum of (Mangled.t * const) list (** program expressions *) and exp = @@ -1339,14 +1338,6 @@ and typ_compare t1 t2 = | Tstruct _, _ -> - 1 | _, Tstruct _ -> 1 | Tarray (t1, _), Tarray (t2, _) -> typ_compare t1 t2 - | Tarray _, _ -> -1 - | _, Tarray _ -> 1 - | Tenum l1, Tenum l2 -> - (* Here we take as result the first non-zero result when comparing their (constant,value) pair.*) - let compare_pair (n1, e1) (n2, e2) = - let n = Mangled.compare n1 n2 in - if n <> 0 then n else const_compare e1 e2 in - IList.compare compare_pair l1 l2 and typ_opt_compare to1 to2 = match to1, to2 with | None, None -> 0 @@ -2021,9 +2012,6 @@ and pp_type_decl pe pp_base pp_size f = function | Tarray (typ, size) -> let pp_base' fmt () = F.fprintf fmt "%a[%a]" pp_base () (pp_size pe) size in pp_type_decl pe pp_base' pp_size f typ - | Tenum econsts -> - F.fprintf f "enum { %a }" - (pp_seq (fun f (n, e) -> F.fprintf f " (%a, %a) " Mangled.pp n (pp_const pe) e)) econsts (** Pretty print a type with all the details, using the C syntax. *) and pp_typ_full pe = pp_type_decl pe (fun _ () -> ()) pp_exp_full @@ -2243,8 +2231,6 @@ let rec typ_iter_types (f : typ -> unit) typ = | Tarray (t, e) -> typ_iter_types f t; exp_iter_types f e - | Tenum _ -> - () (** Iterate over all the subtypes in the type (including the type itself) *) and exp_iter_types f e = @@ -3379,8 +3365,6 @@ let rec typ_sub (subst: subst) typ = Tptr (typ_sub subst t', pk) | Tarray (t, e) -> Tarray (typ_sub subst t, exp_sub subst e) - | Tenum _ -> - typ and exp_sub (subst: subst) e = match e with diff --git a/infer/src/backend/sil.mli b/infer/src/backend/sil.mli index 05cf668e8..80f556df7 100644 --- a/infer/src/backend/sil.mli +++ b/infer/src/backend/sil.mli @@ -307,7 +307,6 @@ and typ = | Tptr of typ * ptr_kind (** pointer type *) | Tstruct of struct_typ (** Type for a structured value *) | Tarray of typ * exp (** array type with fixed size *) - | Tenum of (Mangled.t * const) list (** Program expressions. *) and exp = diff --git a/infer/src/clang/cTypes.ml b/infer/src/clang/cTypes.ml index b87604f55..7278f24bf 100644 --- a/infer/src/clang/cTypes.ml +++ b/infer/src/clang/cTypes.ml @@ -36,22 +36,6 @@ let classname_of_type typ = "Classname of type cannot be extracted in type %s" (Sil.typ_to_string typ); "undefined" -(* Iterates over the tenv to find the value of the enumeration constant *) -(* using its name Here we assume that the enumeration constant have *) -(* different names. Note: this assumption may not be true all the time. So *) -(* need to be careful and give name that cane ensure uniqueness. In case *) -(* of repeated names it gets the last. *) -let search_enum_type_by_name tenv name = - let found = ref None in - let mname = Mangled.from_string name in - let f _ typ = - match typ with - | Sil.Tenum enum_constants -> - IList.iter (fun (c, v) -> if Mangled.equal c mname then found:= Some v else ()) enum_constants - | _ -> () in - Sil.tenv_iter f tenv; - !found - let mk_classname n ck = Typename.TN_csu (Csu.Class ck, Mangled.from_string n) let mk_structname n = Typename.TN_csu (Csu.Struct, Mangled.from_string n) diff --git a/infer/src/clang/cTypes.mli b/infer/src/clang/cTypes.mli index f05e8458e..6b54f9c5b 100644 --- a/infer/src/clang/cTypes.mli +++ b/infer/src/clang/cTypes.mli @@ -11,8 +11,6 @@ val add_pointer_to_typ : Sil.typ -> Sil.typ -val search_enum_type_by_name : Sil.tenv -> string -> Sil.const option - val classname_of_type : Sil.typ -> string val mk_classname : string -> Csu.class_kind -> Typename.t