[inferbo] SymbolPath: rename Index -> Deref

Reviewed By: ezgicicek

Differential Revision: D13128441

fbshipit-source-id: f6547ed7c
master
Mehdi Bouaziz 6 years ago committed by Facebook Github Bot
parent a93e05e9fe
commit 1f96fd03cc

@ -310,7 +310,7 @@ module Init = struct
| {desc= Typ.Tarray {elt}} -> | {desc= Typ.Tarray {elt}} ->
BoUtils.Exec.decl_sym_arr BoUtils.Exec.decl_sym_arr
~decl_sym_val:(decl_sym_val ~may_last_field:false) ~decl_sym_val:(decl_sym_val ~may_last_field:false)
Symb.SymbolPath.CSymArray_Array pname symbol_table path tenv ~node_hash location Symb.SymbolPath.Deref_ArrayIndex pname symbol_table path tenv ~node_hash location
~depth loc elt ~inst_num ~new_sym_num ~new_alloc_num mem ~depth loc elt ~inst_num ~new_sym_num ~new_alloc_num mem
| _ -> | _ ->
BoUtils.Exec.decl_sym_java_ptr BoUtils.Exec.decl_sym_java_ptr
@ -318,7 +318,7 @@ module Init = struct
pname path tenv ~node_hash location ~depth loc typ ~inst_num ~new_alloc_num mem ) pname path tenv ~node_hash location ~depth loc typ ~inst_num ~new_alloc_num mem )
| Typ.Tptr (typ, _) -> | Typ.Tptr (typ, _) ->
BoUtils.Exec.decl_sym_arr ~decl_sym_val:(decl_sym_val ~may_last_field) BoUtils.Exec.decl_sym_arr ~decl_sym_val:(decl_sym_val ~may_last_field)
Symb.SymbolPath.CSymArray_Pointer pname symbol_table path tenv ~node_hash location Symb.SymbolPath.Deref_CPointer pname symbol_table path tenv ~node_hash location
~depth loc typ ~inst_num ~new_sym_num ~new_alloc_num mem ~depth loc typ ~inst_num ~new_sym_num ~new_alloc_num mem
| Typ.Tarray {elt; length; stride} -> | Typ.Tarray {elt; length; stride} ->
let size = let size =
@ -332,7 +332,7 @@ module Init = struct
let stride = Option.map ~f:IntLit.to_int_exn stride in let stride = Option.map ~f:IntLit.to_int_exn stride in
BoUtils.Exec.decl_sym_arr BoUtils.Exec.decl_sym_arr
~decl_sym_val:(decl_sym_val ~may_last_field:false) ~decl_sym_val:(decl_sym_val ~may_last_field:false)
Symb.SymbolPath.CSymArray_Array pname symbol_table path tenv ~node_hash location Symb.SymbolPath.Deref_ArrayIndex pname symbol_table path tenv ~node_hash location
~depth loc elt ~offset ?size ?stride ~inst_num ~new_sym_num ~new_alloc_num mem ~depth loc elt ~offset ?size ?stride ~inst_num ~new_sym_num ~new_alloc_num mem
| Typ.Tstruct typename -> ( | Typ.Tstruct typename -> (
match Models.TypName.dispatch tenv typename with match Models.TypName.dispatch tenv typename with

@ -324,7 +324,7 @@ module StdArray = struct
loc ~inst_num ~new_sym_num ~new_alloc_num mem = loc ~inst_num ~new_sym_num ~new_alloc_num mem =
let offset = Itv.zero in let offset = Itv.zero in
let size = Itv.of_int64 length in let size = Itv.of_int64 length in
BoUtils.Exec.decl_sym_arr ~decl_sym_val Symb.SymbolPath.CSymArray_Array pname symbol_table BoUtils.Exec.decl_sym_arr ~decl_sym_val Symb.SymbolPath.Deref_ArrayIndex pname symbol_table
path tenv ~node_hash location ~depth loc typ ~offset ~size ~inst_num ~new_sym_num path tenv ~node_hash location ~depth loc typ ~offset ~size ~inst_num ~new_sym_num
~new_alloc_num mem ~new_alloc_num mem
in in

@ -318,7 +318,7 @@ let rec eval_sympath_partial params p mem =
L.(debug BufferOverrun Verbose) L.(debug BufferOverrun Verbose)
"Symbol %a is not found in parameters.@\n" (Pvar.pp Pp.text) x ; "Symbol %a is not found in parameters.@\n" (Pvar.pp Pp.text) x ;
Val.Itv.top ) Val.Itv.top )
| Symb.SymbolPath.Index _ | Symb.SymbolPath.Field _ -> | Symb.SymbolPath.Deref _ | Symb.SymbolPath.Field _ ->
let locs = eval_locpath params p mem in let locs = eval_locpath params p mem in
Mem.find_set locs mem Mem.find_set locs mem
@ -328,7 +328,7 @@ and eval_locpath params p mem =
| Symb.SymbolPath.Pvar _ -> | Symb.SymbolPath.Pvar _ ->
let v = eval_sympath_partial params p mem in let v = eval_sympath_partial params p mem in
Val.get_all_locs v Val.get_all_locs v
| Symb.SymbolPath.Index (_, p) -> | Symb.SymbolPath.Deref (_, p) ->
let v = eval_sympath_partial params p mem in let v = eval_sympath_partial params p mem in
Val.get_all_locs v Val.get_all_locs v
| Symb.SymbolPath.Field (fn, p) -> | Symb.SymbolPath.Field (fn, p) ->

@ -126,7 +126,7 @@ module Exec = struct
let decl_sym_arr : let decl_sym_arr :
decl_sym_val:decl_sym_val decl_sym_val:decl_sym_val
-> Symb.SymbolPath.c_sym_array_kind -> Symb.SymbolPath.deref_kind
-> Typ.Procname.t -> Typ.Procname.t
-> Itv.SymbolTable.t -> Itv.SymbolTable.t
-> Itv.SymbolPath.partial -> Itv.SymbolPath.partial
@ -144,7 +144,7 @@ module Exec = struct
-> new_alloc_num:Counter.t -> new_alloc_num:Counter.t
-> Dom.Mem.astate -> Dom.Mem.astate
-> Dom.Mem.astate = -> Dom.Mem.astate =
fun ~decl_sym_val array_kind pname symbol_table path tenv ~node_hash location ~depth loc typ fun ~decl_sym_val deref_kind pname symbol_table path tenv ~node_hash location ~depth loc typ
?offset ?size ?stride ~inst_num ~new_sym_num ~new_alloc_num mem -> ?offset ?size ?stride ~inst_num ~new_sym_num ~new_alloc_num mem ->
let option_value opt_x default_f = match opt_x with Some x -> x | None -> default_f () in let option_value opt_x default_f = match opt_x with Some x -> x | None -> default_f () in
let offset = let offset =
@ -156,7 +156,7 @@ module Exec = struct
Itv.make_sym ~unsigned:true pname symbol_table (Itv.SymbolPath.length path) new_sym_num Itv.make_sym ~unsigned:true pname symbol_table (Itv.SymbolPath.length path) new_sym_num
) )
in in
let deref_path = Itv.SymbolPath.index ~array_kind path in let deref_path = Itv.SymbolPath.deref ~deref_kind path in
let allocsite = let allocsite =
let alloc_num = Counter.next new_alloc_num in let alloc_num = Counter.next new_alloc_num in
Allocsite.make pname ~node_hash ~inst_num ~dimension:alloc_num ~path:(Some deref_path) Allocsite.make pname ~node_hash ~inst_num ~dimension:alloc_num ~path:(Some deref_path)

@ -68,7 +68,7 @@ module Exec : sig
val decl_sym_arr : val decl_sym_arr :
decl_sym_val:decl_sym_val decl_sym_val:decl_sym_val
-> Symb.SymbolPath.c_sym_array_kind -> Symb.SymbolPath.deref_kind
-> Typ.Procname.t -> Typ.Procname.t
-> Itv.SymbolTable.t -> Itv.SymbolTable.t
-> Itv.SymbolPath.partial -> Itv.SymbolPath.partial

@ -16,11 +16,11 @@ module BoundEnd = struct
end end
module SymbolPath = struct module SymbolPath = struct
type c_sym_array_kind = CSymArray_Array | CSymArray_Pointer [@@deriving compare] type deref_kind = Deref_ArrayIndex | Deref_CPointer [@@deriving compare]
type partial = type partial =
| Pvar of Pvar.t | Pvar of Pvar.t
| Index of c_sym_array_kind * partial | Deref of deref_kind * partial
| Field of Typ.Fieldname.t * partial | Field of Typ.Fieldname.t * partial
[@@deriving compare] [@@deriving compare]
@ -32,7 +32,7 @@ module SymbolPath = struct
let field p fn = Field (fn, p) let field p fn = Field (fn, p)
let index ~array_kind p = Index (array_kind, p) let deref ~deref_kind p = Deref (deref_kind, p)
let normal p = Normal p let normal p = Normal p
@ -43,7 +43,7 @@ module SymbolPath = struct
let rec pp_partial fmt = function let rec pp_partial fmt = function
| Pvar pvar -> | Pvar pvar ->
Pvar.pp_value fmt pvar Pvar.pp_value fmt pvar
| Index (_, p) -> | Deref (_, p) ->
F.fprintf fmt "%a[*]" pp_partial p F.fprintf fmt "%a[*]" pp_partial p
| Field (fn, p) -> | Field (fn, p) ->
F.fprintf fmt "%a.%s" pp_partial p (Typ.Fieldname.to_flat_string fn) F.fprintf fmt "%a.%s" pp_partial p (Typ.Fieldname.to_flat_string fn)
@ -61,9 +61,9 @@ module SymbolPath = struct
let rec represents_multiple_values = function let rec represents_multiple_values = function
| Pvar _ -> | Pvar _ ->
false false
| Index (CSymArray_Array, _) -> | Deref (Deref_ArrayIndex, _) ->
true true
| Index (CSymArray_Pointer, p) | Deref (Deref_CPointer, p)
(* unsound but avoids many FPs for non-array pointers *) (* unsound but avoids many FPs for non-array pointers *)
| Field (_, p) -> | Field (_, p) ->
represents_multiple_values p represents_multiple_values p

@ -15,11 +15,11 @@ module BoundEnd : sig
end end
module SymbolPath : sig module SymbolPath : sig
type c_sym_array_kind = CSymArray_Array | CSymArray_Pointer [@@deriving compare] type deref_kind = Deref_ArrayIndex | Deref_CPointer [@@deriving compare]
type partial = private type partial = private
| Pvar of Pvar.t | Pvar of Pvar.t
| Index of c_sym_array_kind * partial | Deref of deref_kind * partial
| Field of Typ.Fieldname.t * partial | Field of Typ.Fieldname.t * partial
[@@deriving compare] [@@deriving compare]
@ -31,7 +31,7 @@ module SymbolPath : sig
val of_pvar : Pvar.t -> partial val of_pvar : Pvar.t -> partial
val index : array_kind:c_sym_array_kind -> partial -> partial val deref : deref_kind:deref_kind -> partial -> partial
val field : partial -> Typ.Fieldname.t -> partial val field : partial -> Typ.Fieldname.t -> partial

Loading…
Cancel
Save