CodeQL library for C/C++
codeql/cpp-all 2.0.2 (changelog, source)
Search

Member predicate ForStmt::getAnIterationVariable

Gets a variable that is used as an iteration variable. That is, a variables that is defined, updated or tested in the head of this for statement.

This only has results that are quite certainly loop variables: for complex iterations, it may not return anything.

For example, for

for (i = 0; i < 10; i++) { j++; }

the result is i.

Variable getAnIterationVariable()