Latest available version: IDA and decompilers v8.4.240320sp1 see all releases
Hex-Rays logo State-of-the-art binary code analysis tools
email icon

Definition of a local variable (register or stack) #var #lvar. More...

#include <hexrays.hpp>

Inheritance diagram for lvar_t:
lvar_locator_t

Public Member Functions

 lvar_t (const qstring &n, const vdloc_t &l, ea_t e, const tinfo_t &t, int w, int db)
 
const char * dstr () const
 
bool used () const
 Is the variable used in the code? More...
 
bool typed () const
 Has the variable a type? More...
 
bool mreg_done () const
 Have corresponding microregs been replaced by references to this variable? More...
 
bool has_nice_name () const
 Does the variable have a nice name? More...
 
bool is_unknown_width () const
 Do we know the width of the variable? More...
 
bool has_user_info () const
 Has any user-defined information? More...
 
bool has_user_name () const
 Has user-defined name? More...
 
bool has_user_type () const
 Has user-defined type? More...
 
bool is_result_var () const
 Is the function result? More...
 
bool is_arg_var () const
 Is the function argument? More...
 
bool is_promoted_arg () const
 Is the promoted function argument? More...
 
bool is_fake_var () const
 Is fake return variable? More...
 
bool is_overlapped_var () const
 Is overlapped variable? More...
 
bool is_floating_var () const
 Used by a fpu insn? More...
 
bool is_spoiled_var () const
 Is spoiled var? (meaningful only during lvar allocation) More...
 
bool is_partialy_typed () const
 Variable type should be handled as a partial one. More...
 
bool is_noptr_var () const
 Variable type should not be a pointer. More...
 
bool is_mapdst_var () const
 Other variable(s) map to this var? More...
 
bool is_thisarg () const
 Is 'this' argument of a C++ member function? More...
 
bool is_split_var () const
 Is a split variable? More...
 
bool has_regname () const
 Has a register name? (like _RAX) More...
 
bool in_asm () const
 Is variable used in an instruction translated into __asm? More...
 
bool is_dummy_arg () const
 Is a dummy argument (added to fill a hole in the argument list) More...
 
bool is_notarg () const
 Is a local variable? (local variable cannot be an input argument) More...
 
bool is_automapped () const
 Was the variable automatically mapped to another variable? More...
 
bool is_used_byref () const
 Was the address of the variable taken? More...
 
bool is_decl_unused () const
 Was declared as __unused by the user? See CVAR_UNUSED. More...
 
bool is_shared () const
 Is lvar mapped to several chains. More...
 
void set_used ()
 
void clear_used ()
 
void set_typed ()
 
void set_non_typed ()
 
void clr_user_info ()
 
void set_user_name ()
 
void set_user_type ()
 
void clr_user_type ()
 
void clr_user_name ()
 
void set_mreg_done ()
 
void clr_mreg_done ()
 
void set_unknown_width ()
 
void clr_unknown_width ()
 
void set_arg_var ()
 
void clr_arg_var ()
 
void set_fake_var ()
 
void clr_fake_var ()
 
void set_overlapped_var ()
 
void clr_overlapped_var ()
 
void set_floating_var ()
 
void clr_floating_var ()
 
void set_spoiled_var ()
 
void clr_spoiled_var ()
 
void set_mapdst_var ()
 
void clr_mapdst_var ()
 
void set_partialy_typed ()
 
void clr_partialy_typed ()
 
void set_noptr_var ()
 
void clr_noptr_var ()
 
void set_thisarg ()
 
void clr_thisarg ()
 
void set_split_var ()
 
void clr_split_var ()
 
void set_dummy_arg ()
 
void clr_dummy_arg ()
 
void set_notarg ()
 
void clr_notarg ()
 
void set_automapped ()
 
void clr_automapped ()
 
void set_used_byref ()
 
void clr_used_byref ()
 
void set_decl_unused ()
 
void clr_decl_unused ()
 
void set_shared ()
 
void clr_shared ()
 
bool has_common (const lvar_t &v) const
 Do variables overlap? More...
 
bool has_common_bit (const vdloc_t &loc, asize_t width2) const
 Does the variable overlap with the specified location? More...
 
const tinfo_t & type () const
 Get variable type. More...
 
tinfo_t & type ()
 
bool accepts_type (const tinfo_t &t, bool may_change_thisarg=false)
 Check if the variable accept the specified type. More...
 
bool set_lvar_type (const tinfo_t &t, bool may_fail=false)
 Set variable type Note: this function does not modify the idb, only the lvar instance in the memory. More...
 
void set_final_lvar_type (const tinfo_t &t)
 Set final variable type. More...
 
bool set_width (int w, int svw_flags=0)
 Change the variable width. More...
 
void append_list (const mba_t *mba, mlist_t *lst, bool pad_if_scattered=false) const
 Append local variable to mlist. More...
 
bool is_aliasable (const mba_t *mba) const
 Is the variable aliasable? More...
 
- Public Member Functions inherited from lvar_locator_t
 lvar_locator_t (const vdloc_t &loc, ea_t ea)
 
sval_t get_stkoff () const
 Get offset of the varialbe in the stack frame. More...
 
bool is_reg1 () const
 Is variable located on one register? More...
 
bool is_reg2 () const
 Is variable located on two registers? More...
 
bool is_reg_var () const
 Is variable located on register(s)? More...
 
bool is_stk_var () const
 Is variable located on the stack? More...
 
bool is_scattered () const
 Is variable scattered? More...
 
mreg_t get_reg1 () const
 Get the register number of the variable. More...
 
mreg_t get_reg2 () const
 Get the number of the second register (works only for ALOC_REG2 lvars) More...
 
const scattered_aloc_t & get_scattered () const
 Get information about scattered variable. More...
 
scattered_aloc_t & get_scattered ()
 
 DECLARE_COMPARISONS (lvar_locator_t)
 
const char * dstr () const
 

Public Attributes

qstring name
 variable name. More...
 
qstring cmt
 variable comment string More...
 
tinfo_t tif
 variable type More...
 
int width = 0
 variable size in bytes More...
 
int defblk = -1
 first block defining the variable. More...
 
uint64 divisor = 0
 max known divisor of the variable More...
 
- Public Attributes inherited from lvar_locator_t
vdloc_t location
 Variable location. More...
 
ea_t defea = BADADDR
 Definition address. More...
 

Friends

class mba_t
 

Detailed Description

Definition of a local variable (register or stack) #var #lvar.

Examples
hexrays_sample18.cpp.

Definition at line 1162 of file hexrays.hpp.

Constructor & Destructor Documentation

◆ lvar_t() [1/2]

lvar_t::lvar_t ( )

Definition at line 1213 of file hexrays.hpp.

◆ lvar_t() [2/2]

lvar_t::lvar_t ( const qstring &  n,
const vdloc_t l,
ea_t  e,
const tinfo_t &  t,
int  w,
int  db 
)

Definition at line 1214 of file hexrays.hpp.

Member Function Documentation

◆ accepts_type()

bool lvar_t::accepts_type ( const tinfo_t &  t,
bool  may_change_thisarg = false 
)

Check if the variable accept the specified type.

Some types are forbidden (void, function types, wrong arrays, etc)

Definition at line 10042 of file hexrays.hpp.

◆ append_list()

void lvar_t::append_list ( const mba_t mba,
mlist_t lst,
bool  pad_if_scattered = false 
) const

Append local variable to mlist.

Parameters
mbaptr to the current mba_t
lstlist to append to
pad_if_scatteredif true, append padding bytes in case of scattered lvar

Definition at line 10060 of file hexrays.hpp.

◆ clear_used()

void lvar_t::clear_used ( )

Definition at line 1282 of file hexrays.hpp.

◆ clr_arg_var()

void lvar_t::clr_arg_var ( )

Definition at line 1295 of file hexrays.hpp.

◆ clr_automapped()

void lvar_t::clr_automapped ( )

Definition at line 1319 of file hexrays.hpp.

◆ clr_decl_unused()

void lvar_t::clr_decl_unused ( )

Definition at line 1323 of file hexrays.hpp.

◆ clr_dummy_arg()

void lvar_t::clr_dummy_arg ( )

Definition at line 1315 of file hexrays.hpp.

◆ clr_fake_var()

void lvar_t::clr_fake_var ( )

Definition at line 1297 of file hexrays.hpp.

◆ clr_floating_var()

void lvar_t::clr_floating_var ( )

Definition at line 1301 of file hexrays.hpp.

◆ clr_mapdst_var()

void lvar_t::clr_mapdst_var ( )

Definition at line 1305 of file hexrays.hpp.

◆ clr_mreg_done()

void lvar_t::clr_mreg_done ( )

Definition at line 1291 of file hexrays.hpp.

◆ clr_noptr_var()

void lvar_t::clr_noptr_var ( )

Definition at line 1309 of file hexrays.hpp.

◆ clr_notarg()

void lvar_t::clr_notarg ( )

Definition at line 1317 of file hexrays.hpp.

◆ clr_overlapped_var()

void lvar_t::clr_overlapped_var ( )

Definition at line 1299 of file hexrays.hpp.

◆ clr_partialy_typed()

void lvar_t::clr_partialy_typed ( )

Definition at line 1307 of file hexrays.hpp.

◆ clr_shared()

void lvar_t::clr_shared ( )

Definition at line 1325 of file hexrays.hpp.

◆ clr_split_var()

void lvar_t::clr_split_var ( )

Definition at line 1313 of file hexrays.hpp.

◆ clr_spoiled_var()

void lvar_t::clr_spoiled_var ( )

Definition at line 1303 of file hexrays.hpp.

◆ clr_thisarg()

void lvar_t::clr_thisarg ( )

Definition at line 1311 of file hexrays.hpp.

◆ clr_unknown_width()

void lvar_t::clr_unknown_width ( )

Definition at line 1293 of file hexrays.hpp.

◆ clr_used_byref()

void lvar_t::clr_used_byref ( )

Definition at line 1321 of file hexrays.hpp.

◆ clr_user_info()

void lvar_t::clr_user_info ( )

Definition at line 1285 of file hexrays.hpp.

◆ clr_user_name()

void lvar_t::clr_user_name ( )

Definition at line 1289 of file hexrays.hpp.

◆ clr_user_type()

void lvar_t::clr_user_type ( )

Definition at line 1288 of file hexrays.hpp.

◆ dstr()

const char * lvar_t::dstr ( ) const

Definition at line 10030 of file hexrays.hpp.

◆ has_common()

bool lvar_t::has_common ( const lvar_t v) const

Do variables overlap?

Definition at line 1328 of file hexrays.hpp.

References arglocs_overlap(), lvar_locator_t::location, and width.

◆ has_common_bit()

bool lvar_t::has_common_bit ( const vdloc_t loc,
asize_t  width2 
) const

Does the variable overlap with the specified location?

Definition at line 1333 of file hexrays.hpp.

References arglocs_overlap().

◆ has_nice_name()

bool lvar_t::has_nice_name ( ) const

Does the variable have a nice name?

Definition at line 1228 of file hexrays.hpp.

References CVAR_NAME.

◆ has_regname()

bool lvar_t::has_regname ( ) const

Has a register name? (like _RAX)

Definition at line 1266 of file hexrays.hpp.

References CVAR_REGNAME.

◆ has_user_info()

bool lvar_t::has_user_info ( ) const

Has any user-defined information?

Definition at line 1232 of file hexrays.hpp.

References CVAR_NOPTR, CVAR_UNAME, CVAR_UNUSED, and CVAR_UTYPE.

◆ has_user_name()

bool lvar_t::has_user_name ( ) const

Has user-defined name?

Definition at line 1238 of file hexrays.hpp.

References CVAR_UNAME.

◆ has_user_type()

bool lvar_t::has_user_type ( ) const

Has user-defined type?

Definition at line 1240 of file hexrays.hpp.

References CVAR_UTYPE.

◆ in_asm()

bool lvar_t::in_asm ( ) const

Is variable used in an instruction translated into __asm?

Definition at line 1268 of file hexrays.hpp.

References CVAR_INASM.

◆ is_aliasable()

bool lvar_t::is_aliasable ( const mba_t mba) const

Is the variable aliasable?

Parameters
mbaptr to the current mba_t Aliasable variables may be modified indirectly (through a pointer)

Definition at line 1384 of file hexrays.hpp.

◆ is_arg_var()

bool lvar_t::is_arg_var ( ) const

Is the function argument?

Definition at line 1244 of file hexrays.hpp.

References CVAR_ARG.

◆ is_automapped()

bool lvar_t::is_automapped ( ) const

Was the variable automatically mapped to another variable?

Definition at line 1274 of file hexrays.hpp.

References CVAR_AUTOMAP.

◆ is_decl_unused()

bool lvar_t::is_decl_unused ( ) const

Was declared as __unused by the user? See CVAR_UNUSED.

Definition at line 1278 of file hexrays.hpp.

References CVAR_UNUSED.

◆ is_dummy_arg()

bool lvar_t::is_dummy_arg ( ) const

Is a dummy argument (added to fill a hole in the argument list)

Definition at line 1270 of file hexrays.hpp.

References CVAR_DUMMY.

◆ is_fake_var()

bool lvar_t::is_fake_var ( ) const

Is fake return variable?

Definition at line 1248 of file hexrays.hpp.

References CVAR_FAKE.

◆ is_floating_var()

bool lvar_t::is_floating_var ( ) const

Used by a fpu insn?

Definition at line 1252 of file hexrays.hpp.

References CVAR_FLOAT.

◆ is_mapdst_var()

bool lvar_t::is_mapdst_var ( ) const

Other variable(s) map to this var?

Definition at line 1260 of file hexrays.hpp.

References CVAR_MAPDST.

◆ is_noptr_var()

bool lvar_t::is_noptr_var ( ) const

Variable type should not be a pointer.

Definition at line 1258 of file hexrays.hpp.

References CVAR_NOPTR.

◆ is_notarg()

bool lvar_t::is_notarg ( ) const

Is a local variable? (local variable cannot be an input argument)

Definition at line 1272 of file hexrays.hpp.

References CVAR_NOTARG.

◆ is_overlapped_var()

bool lvar_t::is_overlapped_var ( ) const

Is overlapped variable?

Definition at line 1250 of file hexrays.hpp.

References CVAR_OVER.

◆ is_partialy_typed()

bool lvar_t::is_partialy_typed ( ) const

Variable type should be handled as a partial one.

Definition at line 1256 of file hexrays.hpp.

References CVAR_PARTIAL.

◆ is_promoted_arg()

bool lvar_t::is_promoted_arg ( ) const

Is the promoted function argument?

Definition at line 10036 of file hexrays.hpp.

◆ is_result_var()

bool lvar_t::is_result_var ( ) const

Is the function result?

Definition at line 1242 of file hexrays.hpp.

References CVAR_RESULT.

◆ is_shared()

bool lvar_t::is_shared ( ) const

Is lvar mapped to several chains.

Definition at line 1280 of file hexrays.hpp.

References CVAR_SHARED.

◆ is_split_var()

bool lvar_t::is_split_var ( ) const

Is a split variable?

Definition at line 1264 of file hexrays.hpp.

References CVAR_SPLIT.

◆ is_spoiled_var()

bool lvar_t::is_spoiled_var ( ) const

Is spoiled var? (meaningful only during lvar allocation)

Definition at line 1254 of file hexrays.hpp.

References CVAR_SPOILED.

◆ is_thisarg()

bool lvar_t::is_thisarg ( ) const

Is 'this' argument of a C++ member function?

Definition at line 1262 of file hexrays.hpp.

References CVAR_THISARG.

◆ is_unknown_width()

bool lvar_t::is_unknown_width ( ) const

Do we know the width of the variable?

Definition at line 1230 of file hexrays.hpp.

References CVAR_NOWD.

◆ is_used_byref()

bool lvar_t::is_used_byref ( ) const

Was the address of the variable taken?

Definition at line 1276 of file hexrays.hpp.

References CVAR_BYREF.

◆ mreg_done()

bool lvar_t::mreg_done ( ) const

Have corresponding microregs been replaced by references to this variable?

Definition at line 1226 of file hexrays.hpp.

References CVAR_MREG.

◆ set_arg_var()

void lvar_t::set_arg_var ( )

Definition at line 1294 of file hexrays.hpp.

◆ set_automapped()

void lvar_t::set_automapped ( )

Definition at line 1318 of file hexrays.hpp.

◆ set_decl_unused()

void lvar_t::set_decl_unused ( )

Definition at line 1322 of file hexrays.hpp.

◆ set_dummy_arg()

void lvar_t::set_dummy_arg ( )

Definition at line 1314 of file hexrays.hpp.

◆ set_fake_var()

void lvar_t::set_fake_var ( )

Definition at line 1296 of file hexrays.hpp.

◆ set_final_lvar_type()

void lvar_t::set_final_lvar_type ( const tinfo_t &  t)

Set final variable type.

Definition at line 1357 of file hexrays.hpp.

◆ set_floating_var()

void lvar_t::set_floating_var ( )

Definition at line 1300 of file hexrays.hpp.

◆ set_lvar_type()

bool lvar_t::set_lvar_type ( const tinfo_t &  t,
bool  may_fail = false 
)

Set variable type Note: this function does not modify the idb, only the lvar instance in the memory.

For permanent changes see modify_user_lvars() Also, the variable type is not considered as final by the decompiler and may be modified later by the type derivation. In some cases set_final_var_type() may work better, but it does not do persistent changes to the database neither.

Parameters
tnew type
may_failif false and type is bad, interr
Returns
success

Definition at line 10048 of file hexrays.hpp.

◆ set_mapdst_var()

void lvar_t::set_mapdst_var ( )

Definition at line 1304 of file hexrays.hpp.

◆ set_mreg_done()

void lvar_t::set_mreg_done ( )

Definition at line 1290 of file hexrays.hpp.

◆ set_non_typed()

void lvar_t::set_non_typed ( )

Definition at line 1284 of file hexrays.hpp.

◆ set_noptr_var()

void lvar_t::set_noptr_var ( )

Definition at line 1308 of file hexrays.hpp.

◆ set_notarg()

void lvar_t::set_notarg ( )

Definition at line 1316 of file hexrays.hpp.

◆ set_overlapped_var()

void lvar_t::set_overlapped_var ( )

Definition at line 1298 of file hexrays.hpp.

◆ set_partialy_typed()

void lvar_t::set_partialy_typed ( )

Definition at line 1306 of file hexrays.hpp.

◆ set_shared()

void lvar_t::set_shared ( )

Definition at line 1324 of file hexrays.hpp.

◆ set_split_var()

void lvar_t::set_split_var ( )

Definition at line 1312 of file hexrays.hpp.

◆ set_spoiled_var()

void lvar_t::set_spoiled_var ( )

Definition at line 1302 of file hexrays.hpp.

◆ set_thisarg()

void lvar_t::set_thisarg ( )

Definition at line 1310 of file hexrays.hpp.

◆ set_typed()

void lvar_t::set_typed ( )

Definition at line 1283 of file hexrays.hpp.

◆ set_unknown_width()

void lvar_t::set_unknown_width ( )

Definition at line 1292 of file hexrays.hpp.

◆ set_used()

void lvar_t::set_used ( )

Definition at line 1281 of file hexrays.hpp.

◆ set_used_byref()

void lvar_t::set_used_byref ( )

Definition at line 1320 of file hexrays.hpp.

◆ set_user_name()

void lvar_t::set_user_name ( )

Definition at line 1286 of file hexrays.hpp.

◆ set_user_type()

void lvar_t::set_user_type ( )

Definition at line 1287 of file hexrays.hpp.

◆ set_width()

bool lvar_t::set_width ( int  w,
int  svw_flags = 0 
)

Change the variable width.

We call the variable size 'width', it is represents the number of bytes. This function may change the variable type using set_lvar_type().

Parameters
wnew width
svw_flagscombination of SVW_... bits
Returns
success

Definition at line 10054 of file hexrays.hpp.

◆ type() [1/2]

tinfo_t & lvar_t::type ( )

Definition at line 1339 of file hexrays.hpp.

◆ type() [2/2]

const tinfo_t & lvar_t::type ( ) const

Get variable type.

Definition at line 1338 of file hexrays.hpp.

◆ typed()

bool lvar_t::typed ( ) const

Has the variable a type?

Definition at line 1224 of file hexrays.hpp.

References CVAR_TYPE.

◆ used()

bool lvar_t::used ( ) const

Is the variable used in the code?

Definition at line 1222 of file hexrays.hpp.

References CVAR_USED.

Friends And Related Function Documentation

◆ mba_t

friend class mba_t
friend

Definition at line 1164 of file hexrays.hpp.

Member Data Documentation

◆ cmt

qstring lvar_t::cmt

variable comment string

Definition at line 1206 of file hexrays.hpp.

◆ defblk

int lvar_t::defblk = -1

first block defining the variable.

0 for args, -1 if unknown

Definition at line 1209 of file hexrays.hpp.

◆ divisor

uint64 lvar_t::divisor = 0

max known divisor of the variable

Definition at line 1211 of file hexrays.hpp.

◆ name

qstring lvar_t::name

variable name.

use mba_t::set_nice_lvar_name() and mba_t::set_user_lvar_name() to modify it

Definition at line 1203 of file hexrays.hpp.

◆ tif

tinfo_t lvar_t::tif

variable type

Definition at line 1207 of file hexrays.hpp.

◆ width

int lvar_t::width = 0

variable size in bytes

Definition at line 1208 of file hexrays.hpp.

Referenced by has_common().