[cleanup] Killed Const.Cptr_to_fld and Binop.PtrFld

Reviewed By: jberdine

Differential Revision: D5370304

fbshipit-source-id: 6b6e960
master
Mehdi Bouaziz 7 years ago committed by Facebook Github Bot
parent f07de2d9c9
commit 7411298def

@ -39,7 +39,6 @@ type t =
| BOr /** inclusive-or */
| LAnd /** logical and. Does not always evaluate both operands. */
| LOr /** logical or. Does not always evaluate both operands. */
| PtrFld /** field offset via pointer to field: takes the address of a Csu.t and a Cptr_to_fld constant to form an Lfield expression (see prop.ml) */
[@@deriving compare];
let equal = [%compare.equal : t];
@ -113,8 +112,7 @@ let text =
| BXor => "^"
| BOr => "|"
| LAnd => "&&"
| LOr => "||"
| PtrFld => "_ptrfld_";
| LOr => "||";
/** Pretty print a binary operator. */

@ -39,7 +39,6 @@ type t =
| BOr /** inclusive-or */
| LAnd /** logical and. Does not always evaluate both operands. */
| LOr /** logical or. Does not always evaluate both operands. */
| PtrFld /** field offset via pointer to field: takes the address of a Csu.t and a Cptr_to_fld constant to form an Lfield expression (see prop.ml) */
[@@deriving compare];
let equal: t => t => bool;

@ -21,7 +21,6 @@ type t =
| Cstr string /** string constants */
| Cfloat float /** float constants */
| Cclass Ident.name /** class constant */
| Cptr_to_fld Typ.Fieldname.t Typ.t /** pointer to field constant, and type of the surrounding Csu.t type */
[@@deriving compare];
let equal = [%compare.equal : t];
@ -33,8 +32,7 @@ let kind_equal c1 c2 => {
| Cfun _ => 2
| Cstr _ => 3
| Cfloat _ => 4
| Cclass _ => 5
| Cptr_to_fld _ => 6;
| Cclass _ => 5;
Int.equal (const_kind_number c1) (const_kind_number c2)
};
@ -48,8 +46,7 @@ let pp pe f =>
}
| Cstr s => F.fprintf f "\"%s\"" (String.escaped s)
| Cfloat v => F.fprintf f "%f" v
| Cclass c => F.fprintf f "%a" Ident.pp_name c
| Cptr_to_fld fn _ => F.fprintf f "__fld_%a" Typ.Fieldname.pp fn;
| Cclass c => F.fprintf f "%a" Ident.pp_name c;
let to_string c => F.asprintf "%a" (pp Pp.text) c;

@ -23,7 +23,6 @@ type t =
| Cstr string /** string constants */
| Cfloat float /** float constants */
| Cclass Ident.name /** class constant */
| Cptr_to_fld Typ.Fieldname.t Typ.t /** pointer to field constant, and type of the surrounding Csu.t type */
[@@deriving compare];
let equal: t => t => bool;

@ -229,7 +229,7 @@ let get_vars exp => {
f::(fun vars_acc (captured_exp, _, _) => get_vars_ captured_exp vars_acc)
init::vars
captured_vars
| Const (Cint _ | Cfun _ | Cstr _ | Cfloat _ | Cclass _ | Cptr_to_fld _) => vars
| Const (Cint _ | Cfun _ | Cstr _ | Cfloat _ | Cclass _) => vars
/* TODO: Sizeof dynamic length expressions may contain variables, do not ignore them. */
| Sizeof _ => vars
};

@ -1441,7 +1441,7 @@ let rec exp_fav_add fav e =>
| Var id => fav ++ id
| Exn e => exp_fav_add fav e
| Closure {captured_vars} => List.iter f::(fun (e, _, _) => exp_fav_add fav e) captured_vars
| Const (Cint _ | Cfun _ | Cstr _ | Cfloat _ | Cclass _ | Cptr_to_fld _) => ()
| Const (Cint _ | Cfun _ | Cstr _ | Cfloat _ | Cclass _) => ()
| Cast _ e
| UnOp _ e _ => exp_fav_add fav e
| BinOp _ e1 e2 =>
@ -1877,7 +1877,7 @@ let rec exp_sub_ids (f: subst_fun) exp => {
} else {
Exp.Closure {...c, captured_vars}
}
| Const (Cint _ | Cfun _ | Cstr _ | Cfloat _ | Cclass _ | Cptr_to_fld _) => exp
| Const (Cint _ | Cfun _ | Cstr _ | Cfloat _ | Cclass _) => exp
| Cast t e =>
let e' = exp_sub_ids f e;
let t' = f_typ t;

@ -895,9 +895,6 @@ let _explain_access tenv
| Exp.Cast (_, e') ->
if verbose then (L.d_str "find_outermost_dereference: cast "; Sil.d_exp e; L.d_ln ());
find_outermost_dereference node e'
| Exp.BinOp(Binop.PtrFld, _, e') ->
if verbose then (L.d_str "find_outermost_dereference: PtrFld "; Sil.d_exp e; L.d_ln ());
find_outermost_dereference node e'
| _ ->
if verbose
then

@ -1053,17 +1053,6 @@ module Normalize = struct
| _ ->
if abs then Exp.get_undefined false else BinOp (BXor, e1', e2')
end
| BinOp (PtrFld, e1, e2) ->
let e1' = eval e1 in
let e2' = eval e2 in
begin
match e2' with
| Const (Cptr_to_fld (fn, typ)) ->
eval (Exp.Lfield(e1', fn, typ))
| Const (Cint i) when IntLit.iszero i ->
Exp.zero (* cause a NULL dereference *)
| _ -> BinOp (PtrFld, e1', e2')
end
| Exn _ ->
e
| Lvar _ ->

@ -214,7 +214,6 @@ struct
| Binop.BOr -> Val.unknown_bit v1
| Binop.LAnd -> Val.land_sem v1 v2
| Binop.LOr -> Val.lor_sem v1 v2
| Binop.PtrFld -> raise Not_implemented
let rec eval_locs : Exp.t -> Mem.astate -> Location.t -> Val.t
= fun exp mem loc ->

@ -29,7 +29,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
|> add_address_taken_pvars e2
| Exp.Exn _
| Exp.Closure _
| Exp.Const (Cint _ | Cfun _ | Cstr _ | Cfloat _ | Cclass _ | Cptr_to_fld _)
| Exp.Const (Cint _ | Cfun _ | Cstr _ | Cfloat _ | Cclass _)
| Exp.Var _ | Exp.Sizeof _ ->
astate

Loading…
Cancel
Save