Skip to content

Commit 63f04af

Browse files
authored
Merge pull request github#3312 from hvitved/dataflow/impl-no-postupdate
Data flow: Support stores into nodes that are not `PostUpdateNode`s
2 parents 9210660 + e95cc24 commit 63f04af

23 files changed

+114
-62
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,8 +1060,8 @@ private module LocalFlowBigStep {
10601060
jumpStep(_, node, config) or
10611061
additionalJumpStep(_, node, config) or
10621062
node instanceof ParameterNode or
1063-
node instanceof OutNode or
1064-
node instanceof PostUpdateNode or
1063+
node instanceof OutNodeExt or
1064+
store(_, _, node) or
10651065
read(_, _, node) or
10661066
node instanceof CastNode
10671067
)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,8 +1060,8 @@ private module LocalFlowBigStep {
10601060
jumpStep(_, node, config) or
10611061
additionalJumpStep(_, node, config) or
10621062
node instanceof ParameterNode or
1063-
node instanceof OutNode or
1064-
node instanceof PostUpdateNode or
1063+
node instanceof OutNodeExt or
1064+
store(_, _, node) or
10651065
read(_, _, node) or
10661066
node instanceof CastNode
10671067
)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,8 +1060,8 @@ private module LocalFlowBigStep {
10601060
jumpStep(_, node, config) or
10611061
additionalJumpStep(_, node, config) or
10621062
node instanceof ParameterNode or
1063-
node instanceof OutNode or
1064-
node instanceof PostUpdateNode or
1063+
node instanceof OutNodeExt or
1064+
store(_, _, node) or
10651065
read(_, _, node) or
10661066
node instanceof CastNode
10671067
)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,8 +1060,8 @@ private module LocalFlowBigStep {
10601060
jumpStep(_, node, config) or
10611061
additionalJumpStep(_, node, config) or
10621062
node instanceof ParameterNode or
1063-
node instanceof OutNode or
1064-
node instanceof PostUpdateNode or
1063+
node instanceof OutNodeExt or
1064+
store(_, _, node) or
10651065
read(_, _, node) or
10661066
node instanceof CastNode
10671067
)

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

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -415,8 +415,7 @@ class CastingNode extends Node {
415415
CastingNode() {
416416
this instanceof ParameterNode or
417417
this instanceof CastNode or
418-
this instanceof OutNode or
419-
this.(PostUpdateNode).getPreUpdateNode() instanceof ArgumentNode
418+
this instanceof OutNodeExt
420419
}
421420
}
422421

@@ -564,6 +563,18 @@ class ReturnNodeExt extends Node {
564563
}
565564
}
566565

566+
/**
567+
* A node to which data can flow from a call. Either an ordinary out node
568+
* or a post-update node associated with a call argument.
569+
*/
570+
class OutNodeExt extends Node {
571+
OutNodeExt() {
572+
this instanceof OutNode
573+
or
574+
this.(PostUpdateNode).getPreUpdateNode() instanceof ArgumentNode
575+
}
576+
}
577+
567578
/**
568579
* An extended return kind. A return kind describes how data can be returned
569580
* from a callable. This can either be through a returned value or an updated
@@ -574,7 +585,7 @@ abstract class ReturnKindExt extends TReturnKindExt {
574585
abstract string toString();
575586

576587
/** Gets a node corresponding to data flow out of `call`. */
577-
abstract Node getAnOutNode(DataFlowCall call);
588+
abstract OutNodeExt getAnOutNode(DataFlowCall call);
578589
}
579590

580591
class ValueReturnKind extends ReturnKindExt, TValueReturn {
@@ -586,7 +597,9 @@ class ValueReturnKind extends ReturnKindExt, TValueReturn {
586597

587598
override string toString() { result = kind.toString() }
588599

589-
override Node getAnOutNode(DataFlowCall call) { result = getAnOutNode(call, this.getKind()) }
600+
override OutNodeExt getAnOutNode(DataFlowCall call) {
601+
result = getAnOutNode(call, this.getKind())
602+
}
590603
}
591604

592605
class ParamUpdateReturnKind extends ReturnKindExt, TParamUpdate {
@@ -598,9 +611,9 @@ class ParamUpdateReturnKind extends ReturnKindExt, TParamUpdate {
598611

599612
override string toString() { result = "param update " + pos }
600613

601-
override PostUpdateNode getAnOutNode(DataFlowCall call) {
614+
override OutNodeExt getAnOutNode(DataFlowCall call) {
602615
exists(ArgumentNode arg |
603-
result.getPreUpdateNode() = arg and
616+
result.(PostUpdateNode).getPreUpdateNode() = arg and
604617
arg.argumentOf(call, this.getPosition())
605618
)
606619
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,8 +1060,8 @@ private module LocalFlowBigStep {
10601060
jumpStep(_, node, config) or
10611061
additionalJumpStep(_, node, config) or
10621062
node instanceof ParameterNode or
1063-
node instanceof OutNode or
1064-
node instanceof PostUpdateNode or
1063+
node instanceof OutNodeExt or
1064+
store(_, _, node) or
10651065
read(_, _, node) or
10661066
node instanceof CastNode
10671067
)

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
@@ -1060,8 +1060,8 @@ private module LocalFlowBigStep {
10601060
jumpStep(_, node, config) or
10611061
additionalJumpStep(_, node, config) or
10621062
node instanceof ParameterNode or
1063-
node instanceof OutNode or
1064-
node instanceof PostUpdateNode or
1063+
node instanceof OutNodeExt or
1064+
store(_, _, node) or
10651065
read(_, _, node) or
10661066
node instanceof CastNode
10671067
)

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
@@ -1060,8 +1060,8 @@ private module LocalFlowBigStep {
10601060
jumpStep(_, node, config) or
10611061
additionalJumpStep(_, node, config) or
10621062
node instanceof ParameterNode or
1063-
node instanceof OutNode or
1064-
node instanceof PostUpdateNode or
1063+
node instanceof OutNodeExt or
1064+
store(_, _, node) or
10651065
read(_, _, node) or
10661066
node instanceof CastNode
10671067
)

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
@@ -1060,8 +1060,8 @@ private module LocalFlowBigStep {
10601060
jumpStep(_, node, config) or
10611061
additionalJumpStep(_, node, config) or
10621062
node instanceof ParameterNode or
1063-
node instanceof OutNode or
1064-
node instanceof PostUpdateNode or
1063+
node instanceof OutNodeExt or
1064+
store(_, _, node) or
10651065
read(_, _, node) or
10661066
node instanceof CastNode
10671067
)

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
@@ -1060,8 +1060,8 @@ private module LocalFlowBigStep {
10601060
jumpStep(_, node, config) or
10611061
additionalJumpStep(_, node, config) or
10621062
node instanceof ParameterNode or
1063-
node instanceof OutNode or
1064-
node instanceof PostUpdateNode or
1063+
node instanceof OutNodeExt or
1064+
store(_, _, node) or
10651065
read(_, _, node) or
10661066
node instanceof CastNode
10671067
)

0 commit comments

Comments
 (0)