IRTerm object represents a node in VulHunt’s intermediate representation (IR) of the binary. IR terms form a tree structure that models the lifted code: blocks contain instructions, instructions contain statements, and statements contain expressions. Every element in this tree, from a basic block down to an individual constant, is an IRTerm.
Each term carries a kind that identifies the operation it represents (e.g., ASSIGN, CALL, ADD). Some terms also have a class_kind that classifies them as STMT or EXPR, and TYPE terms have a sub_kind that provides type information (e.g., INT, POINTER, STRUCT).
Not all fields are present on every term. For example, insns is only meaningful on BLOCK terms and lsb/msb only on EXTRACT terms. Accessing an inapplicable field returns nil.
Fields
Methods
Reference
address / next_address
Theaddress field returns the address in the binary associated with this term. The next_address field returns the address immediately following the term. Use has_next_address() to check whether next_address is available before accessing it.
name
The name associated with this term. Returns a value forINTRINSIC terms (the intrinsic’s name), TYPE terms (the type’s display name), and type sub-terms such as STRUCT_FIELD, FUNC_ARG, ENUM_VARIANT, and UNION_VARIANT. Returns nil for other terms.
num_bits / num_bytes
The bit width and byte width of the term. For expressions, this reflects the size of the result. For type terms, it reflects the size of the described type.type / type_name
For terms that carry type information (such as variables or typed expressions),type returns the type as an IRTerm with kind TYPE, and type_name returns the type’s name as a string.
terms
The direct sub-terms (operands) of this term. This is a generic accessor; for more specific traversal, useinsns, stmts, or operands depending on the term’s kind.
variable
Returns theIRTerm associated with this term.
value
Returns the value of the term as aBitVec.
lsb / msb
The least and most significant bit positions, only relevant forEXTRACT terms.
kind / sub_kind / class_kind
These fields classify the term:kindis theIRTermKindidentifying the specific IR operation (e.g.,ADD,CALL,STORE).class_kindis theIRTermClassKindclassifying the term as a statement (STMT) or expression (EXPR).sub_kindis theIRTermSubKindproviding type classification forTYPEterms (e.g.,INT,POINTER,STRUCT).
insns / stmts / operands
Hierarchical accessors for navigating the IR tree:insnsreturns the instructions inside aBLOCKterm.stmtsreturns the statements inside anINSNorPHIterm.operandsreturns the operand expressions of a statement or expression.
struct_fields / function_arguments / function_return_type / enum_variants / union_variants
Type-specific accessors available onTYPE terms:
struct_fieldscontains the fields of a struct type.function_argumentscontains the arguments of a function type.function_return_typecontains the return type of a function type.enum_variantscontains the variants of an enum type.union_variantscontains the variants of a union type.
is_address / is_variable / is_value / is_offset / is_shift_offset
Convenience methods for checking what a term represents without comparingkind directly.
to_bitvec
Converts the term’s value to aBitVec. Useful for extracting constant values from VAL terms for further arithmetic or comparison.