From 0cab96b43efb9b6723e3e16a5ada31f16d6f45c5 Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Wed, 18 Dec 2019 09:32:49 -0800 Subject: [PATCH] [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 --- infer/src/IR/Pvar.ml | 9 +++++++++ infer/src/IR/Pvar.mli | 6 ++++++ infer/src/IR/Sil.ml | 11 +---------- infer/src/IR/Sil.mli | 6 ------ infer/src/biabduction/PropUtil.ml | 4 ++-- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/infer/src/IR/Pvar.ml b/infer/src/IR/Pvar.ml index ab1a1412b..7b694a916 100644 --- a/infer/src/IR/Pvar.ml +++ b/infer/src/IR/Pvar.ml @@ -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)) diff --git a/infer/src/IR/Pvar.mli b/infer/src/IR/Pvar.mli index 244b4db85..232919ea3 100644 --- a/infer/src/IR/Pvar.mli +++ b/infer/src/IR/Pvar.mli @@ -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 *) diff --git a/infer/src/IR/Sil.ml b/infer/src/IR/Sil.ml index 885f9ab38..3dd94a7b3 100644 --- a/infer/src/IR/Sil.ml +++ b/infer/src/IR/Sil.ml @@ -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 diff --git a/infer/src/IR/Sil.mli b/infer/src/IR/Sil.mli index baebd5e7e..631150c51 100644 --- a/infer/src/IR/Sil.mli +++ b/infer/src/IR/Sil.mli @@ -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) *) diff --git a/infer/src/biabduction/PropUtil.ml b/infer/src/biabduction/PropUtil.ml index 2b73cb2f3..dc3d3a2a4 100644 --- a/infer/src/biabduction/PropUtil.ml +++ b/infer/src/biabduction/PropUtil.ml @@ -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] | _ -> []