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

Predicate Cached::asDefinitionImpl

Gets the expression that represents the result of StoreInstruction for dataflow purposes.

For example, consider the following example

int x = 42;     // 1
x = 34;         // 2
++x;            // 3
x++;            // 4
x += 1;         // 5
int y = x += 2; // 6

For (1) the result is 42. For (2) the result is x = 34. For (3) the result is ++x. For (4) the result is x++. For (5) the result is x += 1. For (6) there are two results:

  • For the StoreInstruction generated by x += 2 the result is x += 2
  • For the StoreInstruction generated by int y = ... the result is also x += 2

Import path

import semmle.code.cpp.ir.dataflow.internal.ExprNodes
Expr asDefinitionImpl(StoreInstruction store)