[IR] kill `Exp.get_vars`

Summary: Use `Exp.program_vars` and `Exp.free_vars` instead.

Reviewed By: sblackshear

Differential Revision: D7113575

fbshipit-source-id: 2a4bd00
master
Jules Villard 7 years ago committed by Facebook Github Bot
parent 43d6c17f29
commit d773dedb4b

@ -173,30 +173,6 @@ let le e1 e2 = BinOp (Le, e1, e2)
(** Create expression [e1 < e2] *)
let lt e1 e2 = BinOp (Lt, e1, e2)
(** Extract the ids and pvars from an expression *)
let get_vars exp =
let rec get_vars_ exp vars =
match exp with
| Lvar pvar ->
(fst vars, pvar :: snd vars)
| Var id ->
(id :: fst vars, snd vars)
| Cast (_, e) | UnOp (_, e, _) | Lfield (e, _, _) | Exn e | Sizeof {dynamic_length= Some e} ->
get_vars_ e vars
| BinOp (_, e1, e2) | Lindex (e1, e2) ->
get_vars_ e1 vars |> get_vars_ e2
| Closure {captured_vars} ->
List.fold
~f:(fun vars_acc (captured_exp, _, _) -> get_vars_ captured_exp vars_acc)
~init:vars captured_vars
| Const (Cint _ | Cfun _ | Cstr _ | Cfloat _ | Cclass _) ->
vars
| Sizeof _ ->
vars
in
get_vars_ exp ([], [])
let fold_captured ~f exp acc =
let rec fold_captured_ exp captured_acc =
match exp with

@ -116,9 +116,6 @@ val le : t -> t -> t
val lt : t -> t -> t
(** Create expression [e1 < e2] *)
val get_vars : t -> Ident.t list * Pvar.t list
(** Extract the ids and pvars from an expression *)
val free_vars : t -> Ident.t Sequence.t
(** all the idents appearing in the expression *)

@ -82,7 +82,9 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
Pvar.is_global pv && not (Pvar.is_static_local pv) && not (Pvar.is_pod pv)
&& not (Pvar.is_compile_constant pv) && not (is_compile_time_constructed pdesc pv)
in
Exp.get_vars e |> snd |> List.filter ~f:is_dangerous_global |> GlobalVarSet.of_list
Exp.program_vars e
|> Sequence.fold ~init:GlobalVarSet.empty ~f:(fun gset g ->
if is_dangerous_global g then GlobalVarSet.add g gset else gset )
let filter_global_accesses initialized =

@ -24,15 +24,15 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
type extras = ProcData.no_extras
(* add all of the vars read in [exp] to the live set *)
(** add all of the vars read in [exp] to the live set *)
let exp_add_live exp astate =
let ids, pvars = Exp.get_vars exp in
let astate' =
List.fold ~f:(fun astate_acc id -> Domain.add (Var.of_id id) astate_acc) ~init:astate ids
Exp.free_vars exp
|> Sequence.fold ~init:astate ~f:(fun astate_acc id -> Domain.add (Var.of_id id) astate_acc)
in
List.fold
~f:(fun astate_acc pvar -> Domain.add (Var.of_pvar pvar) astate_acc)
~init:astate' pvars
Exp.program_vars exp
|> Sequence.fold ~init:astate' ~f:(fun astate_acc pvar ->
Domain.add (Var.of_pvar pvar) astate_acc )
let add_live_actuals actuals call_exp live_acc =

Loading…
Cancel
Save