Instruction.next_instructions()

Returns a list of all instructions following the current node in the control flow graph.

next_instructions() → APISet[Instruction]

The difference between the next_instructions() function and next_instruction() is that this function will return all instructions following the current instruction in the CFG (control-flow-graph).

The function is non-recursive (intra-procedural), and thus will not follow function calls; for the recursive (inter-procedural) variant of this function, use extended_next_instructions().

For example, in the function:

function add(uint256 a, uint256 b) internal pure returns (uint256) {
    uint256 c = a + b;
    require(c >= a, "SafeMath: addition overflow");

    return c;
  }

for the instruction:

uint256 c = a + b;

the function will return the instructions:

require(c >= a, "SafeMath: addition overflow");
return c;

Query Example

from glider import *
def query():
  instructions = Functions().with_name("sub").exec(1,1).instructions().exec(1,1)

  return instructions + list(instructions[0].next_instructions())

Output Example

The function returns APISet, instead of APIList, in case the result of the function is used as the return value of the query it must be casted to list()

Last updated