[refactor] Pvar.is_local_to_procedure

Summary: Small refactor as this function belongs more in Pvar than Var.

Reviewed By: skcho

Differential Revision: D28091618

fbshipit-source-id: 259bd82d5
master
Jules Villard 4 years ago committed by Facebook GitHub Bot
parent 96d8c3dc6c
commit 46c0c0297b

@ -335,3 +335,7 @@ end)
let get_pvar_formals (attributes : ProcAttributes.t) =
let pname = attributes.proc_name in
List.map attributes.formals ~f:(fun (name, typ) -> (mk name pname, typ))
let is_local_to_procedure proc_name pvar =
get_declaring_function pvar |> Option.exists ~f:(Procname.equal proc_name)

@ -162,6 +162,8 @@ val is_pod : t -> bool
(** Is the variable's type a "Plain Old Data" type (C++)? Always (potentially incorrectly) returns
[true] for non-globals. *)
val is_local_to_procedure : Procname.t -> t -> bool
val get_initializer_pname : t -> Procname.t option
(** Get the procname of the initializer function for the given global variable *)

@ -48,15 +48,8 @@ let is_none = function LogicalVar id -> Ident.is_none id | _ -> false
let is_this = function ProgramVar pv -> Pvar.is_this pv | LogicalVar _ -> false
let get_declaring_function = function
| LogicalVar _ ->
None
| ProgramVar pvar ->
Pvar.get_declaring_function pvar
let is_local_to_procedure proc_name var =
get_declaring_function var |> Option.exists ~f:(Procname.equal proc_name)
get_pvar var |> Option.exists ~f:(fun pvar -> Pvar.is_local_to_procedure proc_name pvar)
let get_all_vars_in_exp e =

Loading…
Cancel
Save