@@ -494,7 +494,7 @@ private module ReturnNodes {
494
494
/**
495
495
* Gets a direct node that will may be returned when evaluating this node.
496
496
*/
497
- Node getANode ( ) { none ( ) }
497
+ CfgNode getANode ( ) { none ( ) }
498
498
499
499
/** Gets a child that may produce more nodes that may be returned. */
500
500
abstract ReturnContainer getAChild ( ) ;
@@ -503,7 +503,7 @@ private module ReturnNodes {
503
503
* Gets a (possibly transitive) node that may be returned when evaluating
504
504
* this node.
505
505
*/
506
- final Node getAReturnedNode ( ) {
506
+ final CfgNode getAReturnedNode ( ) {
507
507
result = this .getANode ( )
508
508
or
509
509
result = this .getAChild ( ) .getAReturnedNode ( )
@@ -519,7 +519,7 @@ private module ReturnNodes {
519
519
}
520
520
521
521
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 ( ) }
523
523
524
524
final override ReturnContainer getAChild ( ) { none ( ) }
525
525
}
@@ -551,17 +551,25 @@ private module ReturnNodes {
551
551
}
552
552
553
553
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 ( ) }
555
555
556
556
final override ReturnContainer getAChild ( ) { none ( ) }
557
557
}
558
558
559
559
class CmdReturnContainer extends ReturnContainer , Cmd {
560
- final override StmtNode getANode ( ) { result . getStmtNode ( ) .getStmt ( ) = this }
560
+ final override CfgNodes :: StmtCfgNode getANode ( ) { result .getStmt ( ) = this }
561
561
562
562
final override ReturnContainer getAChild ( ) { none ( ) }
563
563
}
564
564
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
+
565
573
class NormalReturnNode extends ReturnNode instanceof NodeImpl {
566
574
NormalReturnNode ( ) {
567
575
exists ( ReturnContainer container |
0 commit comments