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

Ctree item: statement. More...

#include <hexrays.hpp>

Inheritance diagram for cinsn_t:
citem_t ccase_t

Public Member Functions

 cinsn_t (const cinsn_t &r)
 
void swap (cinsn_t &r)
 
cinsn_toperator= (const cinsn_t &r)
 
cinsn_tassign (const cinsn_t &r)
 
 DECLARE_COMPARISONS (cinsn_t)
 
void replace_by (cinsn_t *r)
 Replace the statement. More...
 
void cleanup ()
 Cleanup the statement. More...
 
void zero ()
 Overwrite with zeroes without cleaning memory or deleting children. More...
 
cinsn_tnew_insn (ea_t insn_ea)
 Create a new statement. More...
 
cif_tcreate_if (cexpr_t *cnd)
 Create a new if-statement. More...
 
void print (int indent, vc_printer_t &vp, use_curly_t use_curly=CALC_CURLY_BRACES) const
 Print the statement into many lines. More...
 
void print1 (qstring *vout, const cfunc_t *func) const
 Print the statement into one line. More...
 
bool is_ordinary_flow () const
 Check if the statement passes execution to the next statement. More...
 
bool contains_insn (ctype_t type, int times=1) const
 Check if the statement contains a statement of the specified type. More...
 
bool collect_free_breaks (cinsnptrvec_t *breaks)
 Collect free break statements. More...
 
bool collect_free_continues (cinsnptrvec_t *continues)
 Collect free continue statements. More...
 
bool contains_free_break () const
 Check if the statement has free break statements. More...
 
bool contains_free_continue () const
 Check if the statement has free continue statements. More...
 
const char * dstr () const
 
- Public Member Functions inherited from citem_t
 citem_t (ctype_t o=cot_empty)
 
void swap (citem_t &r)
 Swap two citem_t. More...
 
bool is_expr () const
 Is an expression? More...
 
bool contains_expr (const cexpr_t *e) const
 Does the item contain an expression? More...
 
bool contains_label () const
 Does the item contain a label? More...
 
const citem_tfind_parent_of (const citem_t *sitem) const
 Find parent of the specified item. More...
 
citem_tfind_parent_of (const citem_t *item)
 
citem_tfind_closest_addr (ea_t _ea)
 
void print1 (qstring *vout, const cfunc_t *func) const
 Print item into one line. More...
 

Public Attributes

union {
   cblock_t *   cblock
 details of block-statement More...
 
   cexpr_t *   cexpr
 details of expression-statement More...
 
   cif_t *   cif
 details of if-statement More...
 
   cfor_t *   cfor
 details of for-statement More...
 
   cwhile_t *   cwhile
 details of while-statement More...
 
   cdo_t *   cdo
 details of do-statement More...
 
   cswitch_t *   cswitch
 details of switch-statement More...
 
   creturn_t *   creturn
 details of return-statement More...
 
   cgoto_t *   cgoto
 details of goto-statement More...
 
   casm_t *   casm
 details of asm-statement More...
 
}; 
 
- Public Attributes inherited from citem_t
ea_t ea = BADADDR
 address that corresponds to the item. may be BADADDR More...
 
ctype_t op = cot_empty
 item type More...
 
int label_num = -1
 label number. More...
 
int index = -1
 an index in cfunc_t::treeitems. More...
 

Detailed Description

Ctree item: statement.

Depending on the exact statement type, various fields of the union are used.

Examples
hexrays_sample17.cpp, hexrays_sample3.cpp, hexrays_sample5.cpp, and hexrays_sample7.cpp.

Definition at line 6471 of file hexrays.hpp.

Constructor & Destructor Documentation

◆ cinsn_t() [1/2]

cinsn_t::cinsn_t ( )

Definition at line 6487 of file hexrays.hpp.

◆ cinsn_t() [2/2]

cinsn_t::cinsn_t ( const cinsn_t r)

Definition at line 6488 of file hexrays.hpp.

◆ ~cinsn_t()

cinsn_t::~cinsn_t ( )

Definition at line 6493 of file hexrays.hpp.

Member Function Documentation

◆ assign()

cinsn_t & cinsn_t::assign ( const cinsn_t r)

Definition at line 11847 of file hexrays.hpp.

◆ cleanup()

void cinsn_t::cleanup ( )

Cleanup the statement.

This function properly deletes all children and sets the item type to cit_empty.

Definition at line 11865 of file hexrays.hpp.

◆ collect_free_breaks()

bool cinsn_t::collect_free_breaks ( cinsnptrvec_t breaks)

Collect free break statements.

This function finds all free break statements within the current statement. A break statement is free if it does not have a loop or switch parent that that is also within the current statement.

Parameters
breakspointer to the variable where the vector of all found free break statements is returned. This argument can be nullptr.
Returns
true if some free break statements have been found

Definition at line 11907 of file hexrays.hpp.

◆ collect_free_continues()

bool cinsn_t::collect_free_continues ( cinsnptrvec_t continues)

Collect free continue statements.

This function finds all free continue statements within the current statement. A continue statement is free if it does not have a loop parent that that is also within the current statement.

Parameters
continuespointer to the variable where the vector of all found free continue statements is returned. This argument can be nullptr.
Returns
true if some free continue statements have been found

Definition at line 11913 of file hexrays.hpp.

◆ contains_free_break()

bool cinsn_t::contains_free_break ( ) const

Check if the statement has free break statements.

Definition at line 6559 of file hexrays.hpp.

◆ contains_free_continue()

bool cinsn_t::contains_free_continue ( ) const

Check if the statement has free continue statements.

Definition at line 6561 of file hexrays.hpp.

◆ contains_insn()

bool cinsn_t::contains_insn ( ctype_t  type,
int  times = 1 
) const

Check if the statement contains a statement of the specified type.

Parameters
typestatement opcode to look for
timeshow many times TYPE should be present
Returns
true if the statement has at least TIMES children with opcode == TYPE

Definition at line 11901 of file hexrays.hpp.

◆ create_if()

cif_t & cinsn_t::create_if ( cexpr_t cnd)

Create a new if-statement.

The current statement must be a block. The new statement will be appended to it.

Parameters
cndif condition. It will be deleted after being copied.

Definition at line 11877 of file hexrays.hpp.

◆ dstr()

const char * cinsn_t::dstr ( ) const

Definition at line 11919 of file hexrays.hpp.

◆ is_ordinary_flow()

bool cinsn_t::is_ordinary_flow ( ) const

Check if the statement passes execution to the next statement.

Returns
false if the statement breaks the control flow (like goto, return, etc)

Definition at line 11895 of file hexrays.hpp.

◆ new_insn()

cinsn_t & cinsn_t::new_insn ( ea_t  insn_ea)

Create a new statement.

The current statement must be a block. The new statement will be appended to it.

Parameters
insn_eastatement address

Definition at line 11871 of file hexrays.hpp.

◆ operator=()

cinsn_t & cinsn_t::operator= ( const cinsn_t r)

Definition at line 6490 of file hexrays.hpp.

◆ print()

void cinsn_t::print ( int  indent,
vc_printer_t vp,
use_curly_t  use_curly = CALC_CURLY_BRACES 
) const

Print the statement into many lines.

Parameters
indentindention (number of spaces) for the statement
vpprinter helper class which will receive the generated text.
use_curlyif the statement is a block, how should curly braces be printed.

Definition at line 11883 of file hexrays.hpp.

◆ print1()

void cinsn_t::print1 ( qstring *  vout,
const cfunc_t func 
) const

Print the statement into one line.

Currently this function is not available.

Parameters
voutoutput buffer
funcparent function. This argument is used to find out the referenced variable names.

Definition at line 11889 of file hexrays.hpp.

◆ replace_by()

void cinsn_t::replace_by ( cinsn_t r)

Replace the statement.

The children of the statement are abandoned (not freed). The statement pointed by 'r' is moved to 'this' statement

Parameters
rthe source statement. It is deleted after being copied

Definition at line 11859 of file hexrays.hpp.

◆ swap()

void cinsn_t::swap ( cinsn_t r)

Definition at line 6489 of file hexrays.hpp.

◆ zero()

void cinsn_t::zero ( )

Overwrite with zeroes without cleaning memory or deleting children.

Definition at line 6506 of file hexrays.hpp.

References cit_empty.

Member Data Documentation

◆ casm

casm_t* cinsn_t::casm

details of asm-statement

Examples
hexrays_sample5.cpp.

Definition at line 6484 of file hexrays.hpp.

◆ cblock

cblock_t* cinsn_t::cblock

details of block-statement

Examples
hexrays_sample7.cpp.

Definition at line 6475 of file hexrays.hpp.

Referenced by ctree_parentee_t::get_block().

◆ cdo

cdo_t* cinsn_t::cdo

details of do-statement

Definition at line 6480 of file hexrays.hpp.

◆ cexpr

cexpr_t* cinsn_t::cexpr

details of expression-statement

Definition at line 6476 of file hexrays.hpp.

◆ cfor

cfor_t* cinsn_t::cfor

details of for-statement

Definition at line 6478 of file hexrays.hpp.

◆ cgoto

cgoto_t* cinsn_t::cgoto

details of goto-statement

Examples
hexrays_sample5.cpp.

Definition at line 6483 of file hexrays.hpp.

◆ cif

cif_t* cinsn_t::cif

details of if-statement

Examples
hexrays_sample3.cpp.

Definition at line 6477 of file hexrays.hpp.

◆ creturn

creturn_t* cinsn_t::creturn

details of return-statement

Definition at line 6482 of file hexrays.hpp.

◆ cswitch

cswitch_t* cinsn_t::cswitch

details of switch-statement

Definition at line 6481 of file hexrays.hpp.

◆ cwhile

cwhile_t* cinsn_t::cwhile

details of while-statement

Definition at line 6479 of file hexrays.hpp.