Skip to content

Commit 67a9562

Browse files
committed
unified: Expose getPostUpdateNode() to avoid internal import
1 parent 785508f commit 67a9562

5 files changed

Lines changed: 26 additions & 23 deletions

File tree

‎unified/ql/lib/codeql/unified/internal/dataflow/DataFlowGraph.qll‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ module DebugGraph<relevantNodeSig/1 relevantNode> {
148148
if isUseStep = true then value = "use-use" else value = "def-use"
149149
)
150150
or
151-
node2 = getPostUpdateNode(node1) and
151+
node2 = node1.getPostUpdateNode() and
152152
value = "post-update"
153153
)
154154
}

‎unified/ql/lib/codeql/unified/internal/dataflow/DataFlowInstantiation.qll‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ module DataFlowInput implements InputSig<Location> {
101101
// Post-update nodes
102102
//
103103
class PostUpdateNode extends Node {
104-
PostUpdateNode() { this = getPostUpdateNode(_) }
104+
PostUpdateNode() { this = any(Node n).getPostUpdateNode() }
105105

106-
Node getPreUpdateNode() { this = getPostUpdateNode(result) }
106+
Node getPreUpdateNode() { this = result.getPostUpdateNode() }
107107
}
108108

109109
//

‎unified/ql/lib/codeql/unified/internal/dataflow/DataFlowNode.qll‎

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -315,21 +315,26 @@ class Node extends TDataFlowNode {
315315

316316
/** Gets the basic block associated with this data flow node, if any. */
317317
BasicBlock getBasicBlock() { this.hasControlFlowPosition(result, _) }
318-
}
319318

320-
Node getPostUpdateNode(Node pre) {
321-
exists(Expr expr |
322-
pre.isResultValue(expr) and
323-
result.isPostUpdate(expr)
324-
)
325-
or
326-
exists(Expr expr, LocalVariable var |
327-
pre.isLocalVariableRead(expr, var) and
328-
result.isLocalVariablePostUpdate(expr, var)
329-
)
330-
or
331-
exists(DataFlowCall call |
332-
pre.isReceiverArgumentEx(call) and
333-
result.isReceiverPostUpdateEx(call)
334-
)
319+
/**
320+
* Gets the post-update node for this node, if any.
321+
*
322+
* The post-update node represents the updated state of the value held in this node, after it has been mutated by the surrounding assignment or call.
323+
*/
324+
Node getPostUpdateNode() {
325+
exists(Expr expr |
326+
this.isResultValue(expr) and
327+
result.isPostUpdate(expr)
328+
)
329+
or
330+
exists(Expr expr, LocalVariable var |
331+
this.isLocalVariableRead(expr, var) and
332+
result.isLocalVariablePostUpdate(expr, var)
333+
)
334+
or
335+
exists(DataFlowCall call |
336+
this.isReceiverArgumentEx(call) and
337+
result.isReceiverPostUpdateEx(call)
338+
)
339+
}
335340
}

‎unified/ql/lib/codeql/unified/internal/dataflow/LocalSsa.qll‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ Node getNodeFromLocalSsaNode(Ssa::Node n) {
9595
result = n.(Ssa::ExprNode).getExpr() and
9696
not postUpdateReadNode(n)
9797
or
98-
result = getPostUpdateNode(n.(Ssa::ExprPostUpdateNode).getExpr())
98+
result = n.(Ssa::ExprPostUpdateNode).getExpr().(Node).getPostUpdateNode()
9999
or
100100
exists(LocalVariable v, BasicBlock bb, int i, AstNode repr |
101101
n.(Ssa::WriteDefSourceNode).getDefinition().definesAt(v, bb, i) and

‎unified/ql/lib/codeql/unified/internal/mad/LegacyMaD.qll‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,6 @@ private DataFlow::Node getSinkFromCall(CallExpr call, AccessPathToken token) {
206206
result.isReceiverArgument(call)
207207
}
208208

209-
private import codeql.unified.internal.dataflow.AllDataFlow
210-
211209
/**
212210
* Gets the output from `call` specified by `token`. Only singleton access paths are supported.
213211
*/
@@ -216,7 +214,7 @@ private DataFlow::Node getSourceFromCall(CallExpr call, AccessPathToken token) {
216214
token = "ReturnValue" and
217215
result.asExpr() = call
218216
or
219-
result = getPostUpdateNode(getSinkFromCall(call, token))
217+
result = getSinkFromCall(call, token).getPostUpdateNode()
220218
}
221219

222220
/**

0 commit comments

Comments
 (0)