CodeQL library for C#
codeql/csharp-all 4.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:

int M(string s) {
  if (s == null)
    throw new ArgumentNullException(nameof(s));
  return s.Length;
}

The basic block starting on line 2 is an immediate dominator of the basic block online 4 (all paths from the entry point of M to return s.Length; must go through the null check.

BasicBlock getImmediateDominator()