Skip to content

Commit 54521ad

Browse files
committed
PS: Add a 'CallNode' helper class.
1 parent b34e369 commit 54521ad

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

powershell/ql/lib/semmle/code/powershell/dataflow/internal/DataFlowPublic.qll

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,25 @@ class Node extends TNode {
3333
Node getASuccessor() { localFlowStep(this, result) }
3434
}
3535

36+
/** A control-flow node, viewed as a node in a data flow graph. */
37+
abstract private class AbstractAstNode extends Node {
38+
CfgNodes::AstCfgNode n;
39+
40+
/** Gets the control-flow node corresponding to this node. */
41+
CfgNodes::AstCfgNode getCfgNode() { result = n }
42+
}
43+
44+
final class AstNode = AbstractAstNode;
45+
3646
/**
3747
* An expression, viewed as a node in a data flow graph.
3848
*
3949
* Note that because of control-flow splitting, one `Expr` may correspond
4050
* to multiple `ExprNode`s, just like it may correspond to multiple
4151
* `ControlFlow::Node`s.
4252
*/
43-
class ExprNode extends Node, TExprNode {
44-
private CfgNodes::ExprCfgNode n;
53+
class ExprNode extends AbstractAstNode, TExprNode {
54+
override CfgNodes::ExprCfgNode n;
4555

4656
ExprNode() { this = TExprNode(n) }
4757

@@ -56,8 +66,8 @@ class ExprNode extends Node, TExprNode {
5666
* to multiple `StmtNode`s, just like it may correspond to multiple
5767
* `ControlFlow::Node`s.
5868
*/
59-
class StmtNode extends Node, TStmtNode {
60-
private CfgNodes::StmtCfgNode n;
69+
class StmtNode extends AbstractAstNode, TStmtNode {
70+
override CfgNodes::StmtCfgNode n;
6171

6272
StmtNode() { this = TStmtNode(n) }
6373

@@ -312,3 +322,12 @@ class ObjectCreationNode extends Node {
312322

313323
final CfgNodes::ObjectCreationCfgNode getObjectCreationNode() { result = objectCreation }
314324
}
325+
326+
/** A call, viewed as a node in a data flow graph. */
327+
class CallNode extends AstNode {
328+
CfgNodes::CallCfgNode call;
329+
330+
CallNode() { call = this.getCfgNode() }
331+
332+
CfgNodes::CallCfgNode getCallNode() { result = call }
333+
}

0 commit comments

Comments
 (0)