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

Member predicate AssignableDefinition::getAFirstRead

Gets a first read of the same underlying assignable. That is, a read that can be reached from this definition without passing through any other reads, and which is guaranteed to read the value assigned in this definition. 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 is first read of the implicit parameter definition on line 3.
  • The read of this.Field on line 5 is a first read of the definition on line 4.

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

AssignableRead getAFirstRead()