diff --git a/infer/src/IR/Exp.ml b/infer/src/IR/Exp.ml index d135a38cf..39d7c9ed1 100644 --- a/infer/src/IR/Exp.ml +++ b/infer/src/IR/Exp.ml @@ -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 diff --git a/infer/src/IR/Exp.mli b/infer/src/IR/Exp.mli index bdd83e950..aefe78b80 100644 --- a/infer/src/IR/Exp.mli +++ b/infer/src/IR/Exp.mli @@ -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 *) diff --git a/infer/src/checkers/Siof.ml b/infer/src/checkers/Siof.ml index 8c52577bd..618a071e0 100644 --- a/infer/src/checkers/Siof.ml +++ b/infer/src/checkers/Siof.ml @@ -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 = diff --git a/infer/src/checkers/liveness.ml b/infer/src/checkers/liveness.ml index 25de8447e..e3268b5af 100644 --- a/infer/src/checkers/liveness.ml +++ b/infer/src/checkers/liveness.ml @@ -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 =