@@ -465,6 +465,17 @@ private predicate finalParameterNodeHasParameterAndIndex(
465
465
n .getIndirectionIndex ( ) = indirectionIndex
466
466
}
467
467
468
+ pragma [ nomagic]
469
+ private predicate hasReturnPosition ( IRFunction f , IRBlock block , int index ) {
470
+ exists ( Instruction return |
471
+ return instanceof ReturnInstruction or
472
+ return instanceof UnreachedInstruction
473
+ |
474
+ block .getInstruction ( index ) = return and
475
+ return .getEnclosingIRFunction ( ) = f
476
+ )
477
+ }
478
+
468
479
class FinalParameterUse extends UseImpl , TFinalParameterUse {
469
480
Parameter p ;
470
481
@@ -493,12 +504,9 @@ class FinalParameterUse extends UseImpl, TFinalParameterUse {
493
504
// `UnreachedInstruction`. If that's the case this predicate will
494
505
// return multiple results. I don't think this is detrimental to
495
506
// performance, however.
496
- exists ( Instruction return |
497
- return instanceof ReturnInstruction or
498
- return instanceof UnreachedInstruction
499
- |
500
- block .getInstruction ( index ) = return and
501
- return .getEnclosingFunction ( ) = p .getFunction ( )
507
+ exists ( IRFunction f |
508
+ hasReturnPosition ( f , block , index ) and
509
+ f .getFunction ( ) = p .getFunction ( )
502
510
)
503
511
}
504
512
@@ -588,13 +596,7 @@ class GlobalUse extends UseImpl, TGlobalUse {
588
596
// globals at any exit so that we can flow out of non-returning functions.
589
597
// Obviously this isn't correct as we can't actually flow but the global flow
590
598
// requires this if we want to flow into children.
591
- exists ( Instruction return |
592
- return instanceof ReturnInstruction or
593
- return instanceof UnreachedInstruction
594
- |
595
- block .getInstruction ( index ) = return and
596
- return .getEnclosingIRFunction ( ) = f
597
- )
599
+ hasReturnPosition ( f , block , index )
598
600
}
599
601
600
602
override BaseSourceVariable getBaseSourceVariable ( ) {
0 commit comments