[SIL] move some stuff to Pvar

Summary: Sil.ml contained utility that belong in Pvar.ml

Reviewed By: ngorogiannis

Differential Revision: D19158532

fbshipit-source-id: 94772baba
master
Jules Villard 5 years ago committed by Facebook Github Bot
parent 30b74413a5
commit 0cab96b43e

@ -300,3 +300,12 @@ let rename ~f {pv_name; pv_kind} =
let pv_name = Mangled.rename ~f pv_name in
let pv_hash = name_hash pv_name in
{pv_hash; pv_name; pv_kind}
let is_objc_static_local_of_proc_name pname pvar =
(* local static name is of the form procname_varname *)
let var_name = Mangled.to_string (get_name pvar) in
match Str.split_delim (Str.regexp_string pname) var_name with [_; _] -> true | _ -> false
let is_block_pvar pvar = Typ.has_block_prefix (Mangled.to_string (get_name pvar))

@ -86,6 +86,12 @@ val is_cpp_temporary : t -> bool
(** return true if this pvar represents a C++ temporary object (see
http://en.cppreference.com/w/cpp/language/lifetime) *)
val is_objc_static_local_of_proc_name : string -> t -> bool
(** Check if a pvar is a local static in objc *)
val is_block_pvar : t -> bool
(** Check if a pvar is a local pointing to a block in objc *)
val mk : Mangled.t -> Typ.Procname.t -> t
(** [mk name proc_name] creates a program var with the given function name *)

@ -214,14 +214,8 @@ let compare_hpara_dll = compare_hpara_dll0 (fun _ _ -> 0)
let equal_hpara_dll = [%compare.equal: hpara_dll]
(** {2 Comparision and Inspection Functions} *)
let is_objc_object = function Hpointsto (_, _, Sizeof {typ}) -> Typ.is_objc_class typ | _ -> false
(** Check if a pvar is a local static in objc *)
let is_static_local_name pname pvar =
(* local static name is of the form procname_varname *)
let var_name = Mangled.to_string (Pvar.get_name pvar) in
match Str.split_delim (Str.regexp_string pname) var_name with [_; _] -> true | _ -> false
let is_objc_object = function Hpointsto (_, _, Sizeof {typ}) -> Typ.is_objc_class typ | _ -> false
(** {2 Sets of heap predicates} *)
module HpredSet = Caml.Set.Make (struct
@ -376,9 +370,6 @@ let add_with_block_parameters_flag instr =
instr
(** Check if a pvar is a local pointing to a block in objc *)
let is_block_pvar pvar = Typ.has_block_prefix (Mangled.to_string (Pvar.get_name pvar))
(** Dump an instruction. *)
let d_instr (i : instr) = L.d_pp_with_pe ~color:Pp.Green (pp_instr ~print_types:true) i

@ -247,12 +247,6 @@ val hpred_compact : sharing_env -> hpred -> hpred
val is_objc_object : hpred -> bool
(** {2 Comparision And Inspection Functions} *)
val is_static_local_name : string -> Pvar.t -> bool
(** Check if a pvar is a local static in objc *)
val is_block_pvar : Pvar.t -> bool
(** Check if a pvar is a local pointing to a block in objc *)
val add_with_block_parameters_flag : instr -> instr
(** Adds a with_blocks_parameters flag to a method call, when the arguments contain an Objective-C
block, and the method is an Objective-C method (to be extended to other methods) *)

@ -16,7 +16,7 @@ let get_name_of_objc_static_locals (curr_f : Procdesc.t) p =
let local_static e =
match e with
| Exp.Lvar pvar
when Pvar.is_global pvar && Sil.is_static_local_name pname pvar
when Pvar.is_global pvar && Pvar.is_objc_static_local_of_proc_name pname pvar
(* is a local static if it's a global and it has a static local name *) ->
[pvar]
| _ ->
@ -32,7 +32,7 @@ let get_name_of_objc_static_locals (curr_f : Procdesc.t) p =
(* returns a list of local variables that points to an objc block in a proposition *)
let get_name_of_objc_block_locals p =
let local_blocks e =
match e with Exp.Lvar pvar when Sil.is_block_pvar pvar -> [pvar] | _ -> []
match e with Exp.Lvar pvar when Pvar.is_block_pvar pvar -> [pvar] | _ -> []
in
let hpred_local_blocks hpred =
match hpred with Sil.Hpointsto (e, _, _) -> [local_blocks e] | _ -> []

Loading…
Cancel
Save