Skip to content

Commit a36bba9

Browse files
committed
C#: Base the getAPostUpdateNote predicate purely on cfg.
1 parent c07c10a commit a36bba9

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

csharp/ql/consistency-queries/DataFlowConsistency.ql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ private class MyConsistencyConfiguration extends ConsistencyConfiguration {
3535
override predicate argHasPostUpdateExclude(ArgumentNode n) {
3636
n instanceof SummaryNode
3737
or
38-
not exists(LocalFlow::getAPostUpdateNodeForArg(n.asExpr()))
38+
not exists(LocalFlow::getAPostUpdateNodeForArg(n.getControlFlowNode()))
3939
or
4040
n instanceof ImplicitCapturedArgumentNode
4141
or
@@ -46,15 +46,15 @@ private class MyConsistencyConfiguration extends ConsistencyConfiguration {
4646

4747
override predicate postHasUniquePreExclude(PostUpdateNode n) {
4848
exists(ControlFlow::Nodes::ExprNode e, ControlFlow::Nodes::ExprNode arg |
49-
e = LocalFlow::getAPostUpdateNodeForArg(arg.getExpr()) and
49+
e = LocalFlow::getAPostUpdateNodeForArg(arg) and
5050
e != arg and
5151
n = TExprPostUpdateNode(e)
5252
)
5353
}
5454

5555
override predicate uniquePostUpdateExclude(Node n) {
5656
exists(ControlFlow::Nodes::ExprNode e, ControlFlow::Nodes::ExprNode arg |
57-
e = LocalFlow::getAPostUpdateNodeForArg(arg.getExpr()) and
57+
e = LocalFlow::getAPostUpdateNodeForArg(arg) and
5858
e != arg and
5959
n.asExpr() = arg.getExpr()
6060
)

csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowPrivate.qll

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -420,8 +420,9 @@ module LocalFlow {
420420
}
421421

422422
/** Gets a node for which to construct a post-update node for argument `arg`. */
423-
ControlFlow::Nodes::ExprNode getAPostUpdateNodeForArg(Argument arg) {
424-
result = getALastEvalNode*(arg.getAControlFlowNode()) and
423+
ControlFlow::Nodes::ExprNode getAPostUpdateNodeForArg(ControlFlow::Nodes::ExprNode arg) {
424+
arg.getExpr() instanceof Argument and
425+
result = getALastEvalNode*(arg) and
425426
exists(Expr e | result.getExpr() = e |
426427
exists(Type t | t = e.stripCasts().getType() |
427428
t instanceof RefType and
@@ -1946,7 +1947,7 @@ private module PostUpdateNodes {
19461947
//
19471948
// This ensures that we get flow out of the call into both leafs (1), while still
19481949
// maintaining the invariant that the underlying expression is a pre-update node (2).
1949-
cfn = LocalFlow::getAPostUpdateNodeForArg(result.asExpr())
1950+
cfn = LocalFlow::getAPostUpdateNodeForArg(result.getControlFlowNode())
19501951
or
19511952
cfn = result.getControlFlowNode()
19521953
}

0 commit comments

Comments
 (0)