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

Predicate validParameterAliasStep

Holds if the data-flow step from node1 to node2 can be used to determine where side-effects may return from a callable. For C/C++, this means that the step from node1 to node2 not only preserves the value, but also preserves the identity of the value. For example, the assignment to x that reads the value of *p in

int* p = ...
int x = *p;

does not preserve the identity of *p.

Similarly, a function that copies the contents of a string into a new location does not also preserve the identity. For example, strdup(p) does not preserve the identity of *p (since it allocates new storage and copies the string into the new storage).

Import path

import semmle.code.cpp.ir.dataflow.internal.DataFlowPrivate
predicate validParameterAliasStep(Node node1, Node node2)