CodeQL library for C#
codeql/csharp-all 0.9.2-dev (changelog, source)
Search

Member predicate Ssa::Definition::getAFirstRead

Gets a read of the source variable underlying this SSA definition that can be reached from this SSA definition without passing through any other SSA definition or read. Example:

int Field;

void SetField(int i) {
  this.Field = i;
  Use(this.Field);
  if (i > 0)
    this.Field = i - 1;
  else if (i < 0)
    SetField(1);
  Use(this.Field);
  Use(this.Field);
}
  • The read of i on line 4 can be reached from the explicit SSA definition (wrapping an implicit entry definition) on line 3.
  • The reads of i on lines 6 and 7 are not the first reads of any SSA definition.
  • The read of this.Field on line 5 can be reached from the explicit SSA definition on line 4.
  • The read of this.Field on line 10 can be reached from the phi node between lines 9 and 10.
  • The read of this.Field on line 11 is not the first read of any SSA definition.

Subsequent reads can be found by following the steps defined by AssignableRead.getANextRead().

AssignableRead getAFirstRead()