CodeQL library for Ruby
codeql/ruby-all 3.0.3-dev (changelog, source)
Search

Member predicate BasicBlock::getImmediateDominator

Gets the basic block that immediately dominates this basic block, if any.

That is, the result is the unique basic block satisfying:

  1. The result strictly dominates this basic block.
  2. There exists no other basic block that is strictly dominated by the result and which strictly dominates this basic block.

All basic blocks, except entry basic blocks, have a unique immediate dominator.

Example:

def m b
  if b
    return 0
  end
  return 1
end

The basic block starting on line 2 is an immediate dominator of the basic block on line 5 (all paths from the entry point of m to return 1 must go through the if block, and the if block is an immediate predecessor of return 1).

BasicBlock getImmediateDominator()