Module IR__Pvar

Program variables.

module F = Stdlib.Format
type translation_unit = IBase.SourceFile.t option
val compare_translation_unit : translation_unit -> translation_unit -> int
type t

Type for program variables. There are 4 kinds of variables:

  1. local variables, used for local variables and formal parameters
  2. callee program variables, used to handle recursion (x | callee is distinguished from x)
  3. global variables
  4. seed variables, used to store the initial value of formal parameters
val compare : t -> t -> int
val yojson_of_t : t -> Ppx_yojson_conv_lib.Yojson.Safe.t
val compare_modulo_this : t -> t -> int

Comparison considering all pvars named 'this'/'self' to be equal

val equal : t -> t -> bool

Equality for pvar's

val get_declaring_function : t -> IR.Procname.t option

if not a global, return function declaring var

val d : t -> unit

Dump a program variable.

val get_name : t -> IR.Mangled.t

Get the name component of a program variable.

val get_ret_pvar : IR.Procname.t -> t

get_ret_pvar proc_name retuns the return pvar associated with the procedure name

val get_ret_param_pvar : IR.Procname.t -> t

get_ret_param_pvar proc_name retuns the return_param pvar associated with the procedure name

val get_simplified_name : t -> string

Get a simplified version of the name component of a program variable.

val is_abduced : t -> bool

Check if the pvar is an abduced return var or param passed by ref

val is_callee : t -> bool

Check if the pvar is a callee var

val is_global : t -> bool

Check if the pvar is a global var or a static local var

val is_static_local : t -> bool

Check if the pvar is a static variable declared inside a function

val is_constant_array : t -> bool

Check if the pvar has a constant array type

val is_const : t -> bool

Check if the pvar has a const type

val is_local : t -> bool

Check if the pvar is a (non-static) local var

val is_seed : t -> bool

Check if the pvar is a seed var

val is_return : t -> bool

Check if the pvar is a return var

val is_this : t -> bool

Check if a pvar is the special "this" var

val is_self : t -> bool

Check if a pvar is the special "self" var

val is_frontend_tmp : t -> bool

return true if pvar is a temporary variable generated by the frontend

val is_clang_tmp : t -> bool

return true if pvar is a temporary variable generated by clang

val is_ssa_frontend_tmp : t -> bool

return true if pvar is a temporary variable generated by the frontend and is only assigned once on a non-looping control-flow path

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 : IR.Mangled.t -> IR.Procname.t -> t

mk name proc_name creates a program var with the given function name

val mk_abduced_ref_param : IR.Procname.t -> int -> IBase.Location.t -> t

create an abduced variable for a parameter passed by reference

val mk_abduced_ret : IR.Procname.t -> IBase.Location.t -> t

create an abduced return variable for a call to proc_name at loc

val mk_callee : IR.Mangled.t -> IR.Procname.t -> t

mk_callee name proc_name creates a program var for a callee function with the given function name

val mk_global : ?⁠is_constexpr:bool -> ?⁠is_ice:bool -> ?⁠is_pod:bool -> ?⁠is_static_local:bool -> ?⁠is_static_global:bool -> ?⁠is_constant_array:bool -> ?⁠is_const:bool -> ?⁠translation_unit:IBase.SourceFile.t -> IR.Mangled.t -> t

create a global variable with the given name

val mk_tmp : string -> IR.Procname.t -> t

create a fresh temporary variable local to procedure pname. for use in the frontends only!

val pp : IStdlib.Pp.env -> F.formatter -> t -> unit

Pretty print a program variable.

val pp_value : F.formatter -> t -> unit

Pretty print a pvar which denotes a value, not an address

val pp_value_non_verbose : F.formatter -> t -> unit

Non-verbose version of pp_value

val pp_translation_unit : F.formatter -> translation_unit -> unit
val to_callee : IR.Procname.t -> t -> t

Turn an ordinary program variable into a callee program variable

val to_seed : t -> t

Turn a pvar into a seed pvar (which stores the initial value of a stack var)

val to_string : t -> string

Convert a pvar to string.

val get_translation_unit : t -> translation_unit

Get the translation unit corresponding to a global. Raises Invalid_arg if not a global.

val is_compile_constant : t -> bool

Is the variable's value a compile-time constant? Always (potentially incorrectly) returns false for non-globals.

val is_ice : t -> bool

Is the variable's type an integral constant expression? Always (potentially incorrectly) returns false for non-globals.

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 : IR.Procname.t -> t -> bool
val get_initializer_pname : t -> IR.Procname.t option

Get the procname of the initializer function for the given global variable

val build_formal_from_pvar : t -> IR.Mangled.t

build_formal_from_pvar var Return a name that is composed of the name of var (and the name of the procname in case of locals)

val materialized_cpp_temporary : string
val swap_proc_in_local_pvar : t -> IR.Procname.t -> t
module Set : IStdlib.PrettyPrintable.PPSet with type PPSet.elt = t

Sets of pvars.

val get_pvar_formals : IR.ProcAttributes.t -> (t * IR.Typ.t) list

Return pvar and type of formal parameters