Skip to content

Commit 4b7813b

Browse files
committed
C++/C#/Java: Split localFlowStep predicate in two
There's now a `localFlowStep` predicate for use directly in queries and other libraries and a `simpleLocalFlowStep` for use only by the global data flow library. The former predicate is intended to include field flow, but the latter may not. This will let Java and C# (and possibly C++ IR) avoid getting two kinds of field flow at the same time, both from SSA and from the global data flow library. It should let C++ AST add some form of field flow to `localFlowStep` without making it an input to the global data flow library.
1 parent c2d1a52 commit 4b7813b

File tree

22 files changed

+61
-19
lines changed

22 files changed

+61
-19
lines changed

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ private predicate isAdditionalFlowStep(
162162
* Holds if data can flow in one local step from `node1` to `node2`.
163163
*/
164164
private predicate localFlowStep(Node node1, Node node2, Configuration config) {
165-
localFlowStep(node1, node2) and
165+
simpleLocalFlowStep(node1, node2) and
166166
not outBarrier(node1, config) and
167167
not inBarrier(node2, config) and
168168
not fullBarrier(node1, config) and

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl2.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ private predicate isAdditionalFlowStep(
162162
* Holds if data can flow in one local step from `node1` to `node2`.
163163
*/
164164
private predicate localFlowStep(Node node1, Node node2, Configuration config) {
165-
localFlowStep(node1, node2) and
165+
simpleLocalFlowStep(node1, node2) and
166166
not outBarrier(node1, config) and
167167
not inBarrier(node2, config) and
168168
not fullBarrier(node1, config) and

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl3.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ private predicate isAdditionalFlowStep(
162162
* Holds if data can flow in one local step from `node1` to `node2`.
163163
*/
164164
private predicate localFlowStep(Node node1, Node node2, Configuration config) {
165-
localFlowStep(node1, node2) and
165+
simpleLocalFlowStep(node1, node2) and
166166
not outBarrier(node1, config) and
167167
not inBarrier(node2, config) and
168168
not fullBarrier(node1, config) and

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl4.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ private predicate isAdditionalFlowStep(
162162
* Holds if data can flow in one local step from `node1` to `node2`.
163163
*/
164164
private predicate localFlowStep(Node node1, Node node2, Configuration config) {
165-
localFlowStep(node1, node2) and
165+
simpleLocalFlowStep(node1, node2) and
166166
not outBarrier(node1, config) and
167167
not inBarrier(node2, config) and
168168
not fullBarrier(node1, config) and

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowUtil.qll

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,8 +422,18 @@ private module ThisFlow {
422422
* Holds if data flows from `nodeFrom` to `nodeTo` in exactly one local
423423
* (intra-procedural) step.
424424
*/
425-
cached
426425
predicate localFlowStep(Node nodeFrom, Node nodeTo) {
426+
simpleLocalFlowStep(nodeFrom, nodeTo)
427+
}
428+
429+
/**
430+
* INTERNAL: do not use.
431+
*
432+
* This is the local flow predicate that's used as a building block in global
433+
* data flow. It may have less flow than the `localFlowStep` predicate.
434+
*/
435+
cached
436+
predicate simpleLocalFlowStep(Node nodeFrom, Node nodeTo) {
427437
// Expr -> Expr
428438
exprToExprStep_nocfg(nodeFrom.asExpr(), nodeTo.asExpr())
429439
or

cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ private predicate isAdditionalFlowStep(
162162
* Holds if data can flow in one local step from `node1` to `node2`.
163163
*/
164164
private predicate localFlowStep(Node node1, Node node2, Configuration config) {
165-
localFlowStep(node1, node2) and
165+
simpleLocalFlowStep(node1, node2) and
166166
not outBarrier(node1, config) and
167167
not inBarrier(node2, config) and
168168
not fullBarrier(node1, config) and

cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl2.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ private predicate isAdditionalFlowStep(
162162
* Holds if data can flow in one local step from `node1` to `node2`.
163163
*/
164164
private predicate localFlowStep(Node node1, Node node2, Configuration config) {
165-
localFlowStep(node1, node2) and
165+
simpleLocalFlowStep(node1, node2) and
166166
not outBarrier(node1, config) and
167167
not inBarrier(node2, config) and
168168
not fullBarrier(node1, config) and

cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl3.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ private predicate isAdditionalFlowStep(
162162
* Holds if data can flow in one local step from `node1` to `node2`.
163163
*/
164164
private predicate localFlowStep(Node node1, Node node2, Configuration config) {
165-
localFlowStep(node1, node2) and
165+
simpleLocalFlowStep(node1, node2) and
166166
not outBarrier(node1, config) and
167167
not inBarrier(node2, config) and
168168
not fullBarrier(node1, config) and

cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl4.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ private predicate isAdditionalFlowStep(
162162
* Holds if data can flow in one local step from `node1` to `node2`.
163163
*/
164164
private predicate localFlowStep(Node node1, Node node2, Configuration config) {
165-
localFlowStep(node1, node2) and
165+
simpleLocalFlowStep(node1, node2) and
166166
not outBarrier(node1, config) and
167167
not inBarrier(node2, config) and
168168
not fullBarrier(node1, config) and

cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,16 @@ UninitializedNode uninitializedNode(LocalVariable v) { result.getLocalVariable()
156156
* (intra-procedural) step.
157157
*/
158158
predicate localFlowStep(Node nodeFrom, Node nodeTo) {
159+
simpleLocalFlowStep(nodeFrom, nodeTo)
160+
}
161+
162+
/**
163+
* INTERNAL: do not use.
164+
*
165+
* This is the local flow predicate that's used as a building block in global
166+
* data flow. It may have less flow than the `localFlowStep` predicate.
167+
*/
168+
predicate simpleLocalFlowStep(Node nodeFrom, Node nodeTo) {
159169
nodeTo.(CopyInstruction).getSourceValue() = nodeFrom or
160170
nodeTo.(PhiInstruction).getAnOperand().getDef() = nodeFrom or
161171
// Treat all conversions as flow, even conversions between different numeric types.

0 commit comments

Comments
 (0)