Skip to content

Commit 706eff2

Browse files
committed
PS: Us control-flow nodes in 'ReturnContainer' instead of dataflow nodes.
1 parent 76bd415 commit 706eff2

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

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

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ private module ReturnNodes {
494494
/**
495495
* Gets a direct node that will may be returned when evaluating this node.
496496
*/
497-
Node getANode() { none() }
497+
CfgNode getANode() { none() }
498498

499499
/** Gets a child that may produce more nodes that may be returned. */
500500
abstract ReturnContainer getAChild();
@@ -503,7 +503,7 @@ private module ReturnNodes {
503503
* Gets a (possibly transitive) node that may be returned when evaluating
504504
* this node.
505505
*/
506-
final Node getAReturnedNode() {
506+
final CfgNode getAReturnedNode() {
507507
result = this.getANode()
508508
or
509509
result = this.getAChild().getAReturnedNode()
@@ -519,7 +519,7 @@ private module ReturnNodes {
519519
}
520520

521521
class CmdExprReturnContainer extends ReturnContainer, CmdExpr {
522-
final override ExprNode getANode() { result.getExprNode().getExpr() = this.getExpr() }
522+
final override CfgNodes::ExprCfgNode getANode() { result.getExpr() = this.getExpr() }
523523

524524
final override ReturnContainer getAChild() { none() }
525525
}
@@ -551,17 +551,25 @@ private module ReturnNodes {
551551
}
552552

553553
class CmdBaseReturnContainer extends ReturnContainer, CmdExpr {
554-
final override ExprNode getANode() { result.getExprNode().getExpr() = this.getExpr() }
554+
final override CfgNodes::ExprCfgNode getANode() { result.getExpr() = this.getExpr() }
555555

556556
final override ReturnContainer getAChild() { none() }
557557
}
558558

559559
class CmdReturnContainer extends ReturnContainer, Cmd {
560-
final override StmtNode getANode() { result.getStmtNode().getStmt() = this }
560+
final override CfgNodes::StmtCfgNode getANode() { result.getStmt() = this }
561561

562562
final override ReturnContainer getAChild() { none() }
563563
}
564564

565+
/** Holds if `n` is returned from the enclosing callable. */
566+
predicate isReturned(CfgNodes::AstCfgNode n) {
567+
exists(ReturnContainer container |
568+
container = n.getScope() and
569+
n = container.getAReturnedNode()
570+
)
571+
}
572+
565573
class NormalReturnNode extends ReturnNode instanceof NodeImpl {
566574
NormalReturnNode() {
567575
exists(ReturnContainer container |

0 commit comments

Comments
 (0)