[hil] rename Write to Assign

Reviewed By: peterogithub

Differential Revision: D5031517

fbshipit-source-id: 5ddfb67
master
Sam Blackshear 8 years ago committed by Facebook Github Bot
parent 491cc2587b
commit 30e629c319

@ -22,13 +22,13 @@ let pp_call fmt = function
| Indirect access_path -> F.fprintf fmt "*%a" AccessPath.Raw.pp access_path | Indirect access_path -> F.fprintf fmt "*%a" AccessPath.Raw.pp access_path
type t = type t =
| Write of AccessPath.Raw.t * HilExp.t * Location.t | Assign of AccessPath.Raw.t * HilExp.t * Location.t
| Assume of HilExp.t * [`Then | `Else] * Sil.if_kind * Location.t | Assume of HilExp.t * [`Then | `Else] * Sil.if_kind * Location.t
| Call of AccessPath.base option * call * HilExp.t list * CallFlags.t * Location.t | Call of AccessPath.base option * call * HilExp.t list * CallFlags.t * Location.t
[@@deriving compare] [@@deriving compare]
let pp fmt = function let pp fmt = function
| Write (access_path, exp, loc) -> | Assign (access_path, exp, loc) ->
F.fprintf fmt "%a := %a [%a]" AccessPath.Raw.pp access_path HilExp.pp exp Location.pp loc F.fprintf fmt "%a := %a [%a]" AccessPath.Raw.pp access_path HilExp.pp exp Location.pp loc
| Assume (exp, _, _, loc) -> | Assume (exp, _, _, loc) ->
F.fprintf fmt "assume %a [%a]" HilExp.pp exp Location.pp loc F.fprintf fmt "assume %a [%a]" HilExp.pp exp Location.pp loc
@ -54,7 +54,7 @@ let of_sil ~f_resolve_id (instr : Sil.instr) =
| [rhs_access_path] -> | [rhs_access_path] ->
Bind (lhs_id, rhs_access_path) Bind (lhs_id, rhs_access_path)
| _ -> | _ ->
Instr (Write (((lhs_id, rhs_typ), []), rhs_hil_exp, loc)) in Instr (Assign (((lhs_id, rhs_typ), []), rhs_hil_exp, loc)) in
match instr with match instr with
| Load (lhs_id, rhs_exp, rhs_typ, loc) -> | Load (lhs_id, rhs_exp, rhs_typ, loc) ->
analyze_id_assignment (Var.of_id lhs_id) rhs_exp rhs_typ loc analyze_id_assignment (Var.of_id lhs_id) rhs_exp rhs_typ loc
@ -70,7 +70,7 @@ let of_sil ~f_resolve_id (instr : Sil.instr) =
match HilExp.of_sil ~f_resolve_id lhs_exp typ with match HilExp.of_sil ~f_resolve_id lhs_exp typ with
| AccessPath ap -> ap | AccessPath ap -> ap
| _ -> invalid_argf "Non-assignable LHS expression %a" Exp.pp lhs_exp in | _ -> invalid_argf "Non-assignable LHS expression %a" Exp.pp lhs_exp in
Instr (Write (lhs_access_path, HilExp.of_sil ~f_resolve_id rhs_exp typ, loc)) Instr (Assign (lhs_access_path, HilExp.of_sil ~f_resolve_id rhs_exp typ, loc))
| Call (ret_opt, call_exp, formals, loc, call_flags) -> | Call (ret_opt, call_exp, formals, loc, call_flags) ->
let hil_ret = Option.map ~f:(fun (ret_id, ret_typ) -> Var.of_id ret_id, ret_typ) ret_opt in let hil_ret = Option.map ~f:(fun (ret_id, ret_typ) -> Var.of_id ret_id, ret_typ) ret_opt in
let hil_call = let hil_call =

@ -20,7 +20,7 @@ type call =
val pp_call : F.formatter -> call -> unit val pp_call : F.formatter -> call -> unit
type t = type t =
| Write of AccessPath.Raw.t * HilExp.t * Location.t | Assign of AccessPath.Raw.t * HilExp.t * Location.t
(** LHS access path, RHS expression *) (** LHS access path, RHS expression *)
| Assume of HilExp.t * [`Then | `Else] * Sil.if_kind * Location.t | Assume of HilExp.t * [`Then | `Else] * Sil.if_kind * Location.t
(** Assumed expression, true_branch boolean, source of the assume (conditional, ternary, etc.) *) (** Assumed expression, true_branch boolean, source of the assume (conditional, ternary, etc.) *)

@ -574,7 +574,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
astate_callee astate_callee
end end
| Write (lhs_access_path, rhs_exp, loc) -> | Assign (lhs_access_path, rhs_exp, loc) ->
let rhs_accesses = let rhs_accesses =
add_access add_access
rhs_exp loc Read astate.accesses astate.locks astate.attribute_map proc_data in rhs_exp loc Read astate.accesses astate.locks astate.attribute_map proc_data in

@ -283,21 +283,21 @@ module Make (TaintSpecification : TaintSpec.S) = struct
~default:TaintDomain.empty_node in ~default:TaintDomain.empty_node in
TaintDomain.add_node (AccessPath.Exact lhs_access_path) rhs_node astate in TaintDomain.add_node (AccessPath.Exact lhs_access_path) rhs_node astate in
match instr with match instr with
| Write (((Var.ProgramVar pvar, _), []), HilExp.Exception _, _) when Pvar.is_return pvar -> | Assign (((Var.ProgramVar pvar, _), []), HilExp.Exception _, _) when Pvar.is_return pvar ->
(* the Java frontend translates `throw Exception` as `return Exception`, which is a bit (* the Java frontend translates `throw Exception` as `return Exception`, which is a bit
wonky. this translation causes problems for us in computing a summary when an wonky. this translation causes problems for us in computing a summary when an
exception is "returned" from a void function. skip code like this for now, fix via exception is "returned" from a void function. skip code like this for now, fix via
t14159157 later *) t14159157 later *)
astate astate
| Write (((Var.ProgramVar pvar, _), []), rhs_exp, _) | Assign (((Var.ProgramVar pvar, _), []), rhs_exp, _)
when Pvar.is_return pvar && HilExp.is_null_literal rhs_exp && when Pvar.is_return pvar && HilExp.is_null_literal rhs_exp &&
Typ.equal_desc Tvoid (Procdesc.get_ret_type proc_data.pdesc).desc -> Typ.equal_desc Tvoid (Procdesc.get_ret_type proc_data.pdesc).desc ->
(* similar to the case above; the Java frontend translates "return no exception" as (* similar to the case above; the Java frontend translates "return no exception" as
`return null` in a void function *) `return null` in a void function *)
astate astate
| Write (lhs_access_path, rhs_exp, _) -> | Assign (lhs_access_path, rhs_exp, _) ->
exec_write lhs_access_path rhs_exp astate exec_write lhs_access_path rhs_exp astate
| Call (ret_opt, Direct called_pname, actuals, call_flags, callee_loc) -> | Call (ret_opt, Direct called_pname, actuals, call_flags, callee_loc) ->

Loading…
Cancel
Save