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

Module DefinitionsAndUses

Provides classes and predicates for reasoning about definitions and uses of variables.

Import path

import semmle.code.cpp.controlflow.DefinitionsAndUses



Provides classes and predicates for working with C/C++ code.



Holds if def is a (potential) assignment to stack variable v. That is, the variable may hold another value in the control-flow node(s) following def than before.


Holds if barrier is either a (potential) definition of v or follows an access that gets the address of v. In both cases, the value of v after barrier cannot be assumed to be the same as before.


Holds if va is a variable passed by reference as argument def, where the callee potentially assigns the corresponding parameter. The definitions-and-uses library models assignment by reference as if it happens on evaluation of the argument, def.


Holds if the definition def of some stack variable can reach node, which is a definition or use, without crossing definitions of the same variable.


Computed relation: A “definition-use-pair” for a particular variable. Intuitively, this means that def is an assignment to var, and use is a read of var at which the value assigned by def may be read. (There can be more than one definition reaching a single use, and a single definition can reach many uses.)


Holds if def is a (definite) assignment to the stack variable v. e is the assigned expression.


Holds if va is a use of the parameter p that could observe the passed-in value.


Holds if use is a non-definition use of stack variable v. This will not include accesses on the LHS of an assignment (which don’t retrieve the variable value), but will include accesses in increment/decrement operations.


Same as useOfVar(v, use), but with the extra condition that the access use actually reads the value of the stack variable v at run-time. (Non-examples include &x and function calls where the callee does not use the relevant parameter.)


A use/use pair is a pair of uses of a particular variable var where the same value might be read (meaning that there is a control-flow path from first to second without crossing a definition of var).



A definition of a stack variable.


Utility class: A definition or use of a stack variable.


A definition of a parameter.


A use of a stack variable.