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

Member predicate ClassAggregateLiteral::getFieldExpr

Gets the expression within the aggregate literal that is used to initialize field field, if present. The expression is the position’th entry in the aggregate literal.

For example, if aggr represents the initialization literal {.x = 123, .y = 456 .x = 789} in

struct Foo { int x; int y; };
struct Foo foo = {.x = 123, .y = 456 .x = 789};

then:

  • aggr.getFieldExpr(x, 0) gives 123.
  • aggr.getFieldExpr(y, 1) gives 456.
  • aggr.getFieldExpr(x, 2) gives 789.
Expr getFieldExpr(Field field, int position)