CodeQL library for C/C++
codeql/cpp-all 2.1.2-dev (changelog, source)
Search

Class Instruction

A single instruction in the IR.

Import path

import semmle.code.cpp.ir.IR

Direct supertypes

Known direct subtypes

Predicates

getAPredecessor

Gets all direct predecessors of this instruction.

getASuccessor

Gets all direct successors of this instruction.

getAUse

Gets all direct uses of the result of this instruction. The result can be an Operand for which isDefinitionInexact holds.

getAnOperand

Gets all of this instruction’s operands.

getAst

Gets the AST that caused this instruction to be generated.

getBackEdgeSuccessor

Gets the a back-edge successor of this instruction along the control flow edge specified by kind. A back edge in the control-flow graph is intuitively the edge that goes back around a loop. If all back edges are removed from the control-flow graph, it becomes acyclic.

getBlock

Gets the basic block that contains this instruction.

getConvertedResultExpression

Gets the Expr whose result is computed by this instruction, if any. The Expr may be a conversion.

getDisplayIndexInBlock

Gets the zero-based index of this instruction within its block. This is used by debugging and printing code only.

getDumpString

Gets a string showing the result, opcode, and operands of the instruction, equivalent to what would be printed by PrintIR.ql. For example:

getEnclosingFunction

Gets the function that contains this instruction.

getEnclosingIRFunction

Gets the IRFunction object that contains the IR for this instruction.

getImmediateString

Gets a string describing the immediate value of this instruction, if any.

getLocation

Gets the location of the source code for this instruction.

getOpcode

Gets the opcode that specifies the operation performed by this instruction.

getOperandsString

Gets a string describing the operands of this instruction, suitable for display in IR dumps.

getOperationString

Gets a string describing the operation of this instruction. This includes the opcode and the immediate value, if any. For example:

getPredecessor

Gets a predecessor of this instruction such that the predecessor reaches this instruction along the control flow edge specified by kind.

getResultAddress

Gets the instruction that holds the exact memory address to which this instruction stores its result, if any. For example, in m3 = Store r1, r2, the result of getResultAddressOperand() is the instruction that defines r1.

getResultAddressOperand

Gets the operand that holds the memory address to which this instruction stores its result, if any. For example, in m3 = Store r1, r2, the result of getResultAddressOperand() is r1.

getResultIRType

Gets the type of the result produced by this instruction. If the instruction does not produce a result, its result type will be IRVoidType.

getResultId

Gets a human-readable string that uniquely identifies this instruction within the function. This string is used to refer to this instruction when printing IR dumps.

getResultLanguageType

Gets the language-specific type of the result produced by this instruction.

getResultMemoryAccess

Gets the kind of memory access performed by this instruction’s result. Holds only for instructions with a memory result.

getResultSize

Gets the size of the result produced by this instruction, in bytes. If the result does not have a known constant size, this predicate does not hold.

getResultString

Gets a string describing the result of this instruction, suitable for display in IR dumps. This consists of the result ID plus the type of the result.

getResultType

Gets the type of the result produced by this instruction. If the instruction does not produce a result, its result type will be VoidType.

getSuccessor

Gets the successor of this instruction along the control flow edge specified by kind.

getUnconvertedResultExpression

Gets the unconverted form of the Expr whose result is computed by this instruction, if any.

getUniqueId

Gets a string identifier for this function that is unique among all instructions in the same function.

hasMemoryResult

Holds if this instruction produces a memory result.

hasResultMayMemoryAccess

Holds if the memory access performed by this instruction’s result will not always write to every bit in the memory location. This is most commonly used for memory accesses that may or may not actually occur depending on runtime state (for example, the write side effect of an output parameter that is not written to on all paths), or for accesses where the memory location is a conservative estimate of the memory that might actually be accessed at runtime (for example, the global side effects of a function call).

hasSortKeys

INTERNAL: Do not use.

isGLValue

Holds if the result produced by this instruction is a glvalue. If this holds, the result of the instruction represents the address of a location, and the type of the location is given by getResultType(). If this does not hold, the result of the instruction represents a value whose type is given by getResultType().

isResultConflated

Holds if this is an instruction with a memory result that represents a conflation of more than one memory allocation.

isResultModeled

Holds if the result of this instruction is precisely modeled in SSA. Always holds for a register result. For a memory result, a modeled result is connected to its actual uses. An unmodeled result has no uses.

toString

Gets a textual representation of this element.

Charpred