From 7411298defc2e4f94c0d4f6587caf6d606c7061b Mon Sep 17 00:00:00 2001 From: Mehdi Bouaziz Date: Mon, 10 Jul 2017 08:04:28 -0700 Subject: [PATCH] [cleanup] Killed Const.Cptr_to_fld and Binop.PtrFld Reviewed By: jberdine Differential Revision: D5370304 fbshipit-source-id: 6b6e960 --- infer/src/IR/Binop.re | 4 +--- infer/src/IR/Binop.rei | 1 - infer/src/IR/Const.re | 7 ++----- infer/src/IR/Const.rei | 1 - infer/src/IR/Exp.re | 2 +- infer/src/IR/Sil.re | 4 ++-- infer/src/backend/errdesc.ml | 3 --- infer/src/backend/prop.ml | 11 ----------- infer/src/bufferoverrun/bufferOverrunSemantics.ml | 1 - infer/src/checkers/addressTaken.ml | 2 +- 10 files changed, 7 insertions(+), 29 deletions(-) diff --git a/infer/src/IR/Binop.re b/infer/src/IR/Binop.re index 1a3a079d2..897e26a73 100644 --- a/infer/src/IR/Binop.re +++ b/infer/src/IR/Binop.re @@ -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. */ diff --git a/infer/src/IR/Binop.rei b/infer/src/IR/Binop.rei index b16424c4c..3b3c102e6 100644 --- a/infer/src/IR/Binop.rei +++ b/infer/src/IR/Binop.rei @@ -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; diff --git a/infer/src/IR/Const.re b/infer/src/IR/Const.re index 0dea6941c..172983aca 100644 --- a/infer/src/IR/Const.re +++ b/infer/src/IR/Const.re @@ -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; diff --git a/infer/src/IR/Const.rei b/infer/src/IR/Const.rei index 75b6c54ca..5cafaf5a9 100644 --- a/infer/src/IR/Const.rei +++ b/infer/src/IR/Const.rei @@ -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; diff --git a/infer/src/IR/Exp.re b/infer/src/IR/Exp.re index 9ada3691a..f2e7ba2e7 100644 --- a/infer/src/IR/Exp.re +++ b/infer/src/IR/Exp.re @@ -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 }; diff --git a/infer/src/IR/Sil.re b/infer/src/IR/Sil.re index 4193848bf..5ea2b3dc1 100644 --- a/infer/src/IR/Sil.re +++ b/infer/src/IR/Sil.re @@ -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; diff --git a/infer/src/backend/errdesc.ml b/infer/src/backend/errdesc.ml index 817a3e2cb..59bc003e5 100644 --- a/infer/src/backend/errdesc.ml +++ b/infer/src/backend/errdesc.ml @@ -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 diff --git a/infer/src/backend/prop.ml b/infer/src/backend/prop.ml index 1eb8da05e..05d3c59b1 100644 --- a/infer/src/backend/prop.ml +++ b/infer/src/backend/prop.ml @@ -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 _ -> diff --git a/infer/src/bufferoverrun/bufferOverrunSemantics.ml b/infer/src/bufferoverrun/bufferOverrunSemantics.ml index 9bd874ca3..6a265f557 100644 --- a/infer/src/bufferoverrun/bufferOverrunSemantics.ml +++ b/infer/src/bufferoverrun/bufferOverrunSemantics.ml @@ -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 -> diff --git a/infer/src/checkers/addressTaken.ml b/infer/src/checkers/addressTaken.ml index 820da9240..1c68a04b4 100644 --- a/infer/src/checkers/addressTaken.ml +++ b/infer/src/checkers/addressTaken.ml @@ -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