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

Member predicate ArrayOrVectorAggregateLiteral::hasDesignator

Holds if the position-th initialization of the array element at elementIndex in this aggregate initializer uses a designated (e.g., [0] = ...) rather than a positional initializer.

For example, in:

int x[] = { [0] = 1, 2 };
  • [0] = 1 is a designated initializer, therefore hasDesignator(0, 0) holds.
  • 2 is a positional initializer for x[1], therefore hasDesignator(1, 1) does not hold.
predicate hasDesignator(int elementIndex, int position)