Skip to content

Commit 172651a

Browse files
committed
Data flow: Support stores into nodes that are not PostUpdateNodes
1 parent 790ac25 commit 172651a

23 files changed

Lines changed: 114 additions & 62 deletions

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,8 +1290,8 @@ private module LocalFlowBigStep {
12901290
jumpStep(_, node, config) or
12911291
additionalJumpStep(_, node, config) or
12921292
node instanceof ParameterNode or
1293-
node instanceof OutNode or
1294-
node instanceof PostUpdateNode or
1293+
node instanceof OutNodeExt or
1294+
storeDirect(_, _, node) or
12951295
readDirect(_, _, node) or
12961296
node instanceof CastNode
12971297
)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,8 +1290,8 @@ private module LocalFlowBigStep {
12901290
jumpStep(_, node, config) or
12911291
additionalJumpStep(_, node, config) or
12921292
node instanceof ParameterNode or
1293-
node instanceof OutNode or
1294-
node instanceof PostUpdateNode or
1293+
node instanceof OutNodeExt or
1294+
storeDirect(_, _, node) or
12951295
readDirect(_, _, node) or
12961296
node instanceof CastNode
12971297
)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,8 +1290,8 @@ private module LocalFlowBigStep {
12901290
jumpStep(_, node, config) or
12911291
additionalJumpStep(_, node, config) or
12921292
node instanceof ParameterNode or
1293-
node instanceof OutNode or
1294-
node instanceof PostUpdateNode or
1293+
node instanceof OutNodeExt or
1294+
storeDirect(_, _, node) or
12951295
readDirect(_, _, node) or
12961296
node instanceof CastNode
12971297
)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,8 +1290,8 @@ private module LocalFlowBigStep {
12901290
jumpStep(_, node, config) or
12911291
additionalJumpStep(_, node, config) or
12921292
node instanceof ParameterNode or
1293-
node instanceof OutNode or
1294-
node instanceof PostUpdateNode or
1293+
node instanceof OutNodeExt or
1294+
storeDirect(_, _, node) or
12951295
readDirect(_, _, node) or
12961296
node instanceof CastNode
12971297
)

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

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -529,8 +529,7 @@ class CastingNode extends Node {
529529
CastingNode() {
530530
this instanceof ParameterNode or
531531
this instanceof CastNode or
532-
this instanceof OutNode or
533-
this.(PostUpdateNode).getPreUpdateNode() instanceof ArgumentNode
532+
this instanceof OutNodeExt
534533
}
535534
}
536535

@@ -678,6 +677,18 @@ class ReturnNodeExt extends Node {
678677
}
679678
}
680679

680+
/**
681+
* A node to which data can flow from a call. Either an ordinary out node
682+
* or a post-update node associated with a call argument.
683+
*/
684+
class OutNodeExt extends Node {
685+
OutNodeExt() {
686+
this instanceof OutNode
687+
or
688+
this.(PostUpdateNode).getPreUpdateNode() instanceof ArgumentNode
689+
}
690+
}
691+
681692
/**
682693
* An extended return kind. A return kind describes how data can be returned
683694
* from a callable. This can either be through a returned value or an updated
@@ -688,7 +699,7 @@ abstract class ReturnKindExt extends TReturnKindExt {
688699
abstract string toString();
689700

690701
/** Gets a node corresponding to data flow out of `call`. */
691-
abstract Node getAnOutNode(DataFlowCall call);
702+
abstract OutNodeExt getAnOutNode(DataFlowCall call);
692703
}
693704

694705
class ValueReturnKind extends ReturnKindExt, TValueReturn {
@@ -700,7 +711,9 @@ class ValueReturnKind extends ReturnKindExt, TValueReturn {
700711

701712
override string toString() { result = kind.toString() }
702713

703-
override Node getAnOutNode(DataFlowCall call) { result = getAnOutNode(call, this.getKind()) }
714+
override OutNodeExt getAnOutNode(DataFlowCall call) {
715+
result = getAnOutNode(call, this.getKind())
716+
}
704717
}
705718

706719
class ParamUpdateReturnKind extends ReturnKindExt, TParamUpdate {
@@ -712,9 +725,9 @@ class ParamUpdateReturnKind extends ReturnKindExt, TParamUpdate {
712725

713726
override string toString() { result = "param update " + pos }
714727

715-
override PostUpdateNode getAnOutNode(DataFlowCall call) {
728+
override OutNodeExt getAnOutNode(DataFlowCall call) {
716729
exists(ArgumentNode arg |
717-
result.getPreUpdateNode() = arg and
730+
result.(PostUpdateNode).getPreUpdateNode() = arg and
718731
arg.argumentOf(call, this.getPosition())
719732
)
720733
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,8 +1290,8 @@ private module LocalFlowBigStep {
12901290
jumpStep(_, node, config) or
12911291
additionalJumpStep(_, node, config) or
12921292
node instanceof ParameterNode or
1293-
node instanceof OutNode or
1294-
node instanceof PostUpdateNode or
1293+
node instanceof OutNodeExt or
1294+
storeDirect(_, _, node) or
12951295
readDirect(_, _, node) or
12961296
node instanceof CastNode
12971297
)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,8 +1290,8 @@ private module LocalFlowBigStep {
12901290
jumpStep(_, node, config) or
12911291
additionalJumpStep(_, node, config) or
12921292
node instanceof ParameterNode or
1293-
node instanceof OutNode or
1294-
node instanceof PostUpdateNode or
1293+
node instanceof OutNodeExt or
1294+
storeDirect(_, _, node) or
12951295
readDirect(_, _, node) or
12961296
node instanceof CastNode
12971297
)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,8 +1290,8 @@ private module LocalFlowBigStep {
12901290
jumpStep(_, node, config) or
12911291
additionalJumpStep(_, node, config) or
12921292
node instanceof ParameterNode or
1293-
node instanceof OutNode or
1294-
node instanceof PostUpdateNode or
1293+
node instanceof OutNodeExt or
1294+
storeDirect(_, _, node) or
12951295
readDirect(_, _, node) or
12961296
node instanceof CastNode
12971297
)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,8 +1290,8 @@ private module LocalFlowBigStep {
12901290
jumpStep(_, node, config) or
12911291
additionalJumpStep(_, node, config) or
12921292
node instanceof ParameterNode or
1293-
node instanceof OutNode or
1294-
node instanceof PostUpdateNode or
1293+
node instanceof OutNodeExt or
1294+
storeDirect(_, _, node) or
12951295
readDirect(_, _, node) or
12961296
node instanceof CastNode
12971297
)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,8 +1290,8 @@ private module LocalFlowBigStep {
12901290
jumpStep(_, node, config) or
12911291
additionalJumpStep(_, node, config) or
12921292
node instanceof ParameterNode or
1293-
node instanceof OutNode or
1294-
node instanceof PostUpdateNode or
1293+
node instanceof OutNodeExt or
1294+
storeDirect(_, _, node) or
12951295
readDirect(_, _, node) or
12961296
node instanceof CastNode
12971297
)

0 commit comments

Comments
 (0)