@@ -148,7 +148,7 @@ abstract private class LocalFunctionCreationNode extends NodeImpl, TLocalFunctio
148
148
LocalFunction getFunction ( ) { result = function }
149
149
150
150
ExprNode getAnAccess ( boolean inSameCallable ) {
151
- result .getExpr ( ) . ( LocalFunctionAccess ) . getTarget ( ) = this .getFunction ( ) and
151
+ isLocalFunctionCallReceiver ( _ , result .getExpr ( ) , this .getFunction ( ) ) and
152
152
if result .getEnclosingCallable ( ) = this .getEnclosingCallable ( )
153
153
then inSameCallable = true
154
154
else inSameCallable = false
@@ -399,7 +399,11 @@ module VariableCapture {
399
399
400
400
predicate hasBody ( Callable body ) { body = c }
401
401
402
- predicate hasAliasedAccess ( Expr f ) { closureFlowStep + ( this , f ) and not closureFlowStep ( f , _) }
402
+ predicate hasAliasedAccess ( Expr f ) {
403
+ closureFlowStep + ( this , f ) and not closureFlowStep ( f , _)
404
+ or
405
+ isLocalFunctionCallReceiver ( _, f .getAstNode ( ) , c )
406
+ }
403
407
}
404
408
405
409
class Callable extends Cs:: Callable {
@@ -881,7 +885,7 @@ module LocalFlow {
881
885
exists ( SsaImpl:: getAReadAtNode ( def , node2 .( ExprNode ) .getControlFlowNode ( ) ) )
882
886
)
883
887
or
884
- delegateCreationStep ( node1 , node2 )
888
+ node2 = node1 . ( LocalFunctionCreationNode ) . getAnAccess ( true )
885
889
or
886
890
node1 =
887
891
unique( FlowSummaryNode n1 |
@@ -2549,9 +2553,10 @@ class DataFlowType extends TDataFlowType {
2549
2553
* creations associated with the same type.
2550
2554
*/
2551
2555
ControlFlowElement getADelegateCreation ( ) {
2552
- exists ( Callable callable |
2553
- lambdaCreationExpr ( result , callable ) and
2554
- this = TDelegateDataFlowType ( callable )
2556
+ exists ( Callable callable | this = TDelegateDataFlowType ( callable ) |
2557
+ lambdaCreationExpr ( result , callable )
2558
+ or
2559
+ isLocalFunctionCallReceiver ( _, result , callable )
2555
2560
)
2556
2561
}
2557
2562
@@ -2566,12 +2571,7 @@ class DataFlowType extends TDataFlowType {
2566
2571
DataFlowType getNodeType ( Node n ) {
2567
2572
result = n .( NodeImpl ) .getDataFlowType ( ) and
2568
2573
not lambdaCreation ( n , _, _) and
2569
- not delegateCreationStep ( _, n )
2570
- or
2571
- exists ( Node arg |
2572
- delegateCreationStep ( arg , n ) and
2573
- result = getNodeType ( arg )
2574
- )
2574
+ not isLocalFunctionCallReceiver ( _, n .asExpr ( ) , _)
2575
2575
or
2576
2576
[
2577
2577
n .asExpr ( ) .( ControlFlowElement ) ,
@@ -2896,7 +2896,7 @@ private predicate lambdaCreationExpr(ControlFlowElement creation, Callable c) {
2896
2896
c =
2897
2897
[
2898
2898
creation .( AnonymousFunctionExpr ) ,
2899
- creation .( CallableAccess ) .getTarget ( ) .getUnboundDeclaration ( ) ,
2899
+ creation .( DelegateCreation ) . getArgument ( ) . ( CallableAccess ) .getTarget ( ) .getUnboundDeclaration ( ) ,
2900
2900
creation .( AddressOfExpr ) .getOperand ( ) .( CallableAccess ) .getTarget ( ) .getUnboundDeclaration ( ) ,
2901
2901
creation .( LocalFunctionStmt ) .getLocalFunction ( )
2902
2902
]
@@ -2910,6 +2910,13 @@ predicate lambdaCreation(Node creation, LambdaCallKind kind, DataFlowCallable c)
2910
2910
exists ( kind )
2911
2911
}
2912
2912
2913
+ private predicate isLocalFunctionCallReceiver (
2914
+ LocalFunctionCall call , LocalFunctionAccess receiver , LocalFunction f
2915
+ ) {
2916
+ receiver .getParent ( ) = call and
2917
+ f = receiver .getTarget ( ) .getUnboundDeclaration ( )
2918
+ }
2919
+
2913
2920
private class LambdaConfiguration extends ControlFlowReachabilityConfiguration {
2914
2921
LambdaConfiguration ( ) { this = "LambdaConfiguration" }
2915
2922
@@ -2926,7 +2933,7 @@ private class LambdaConfiguration extends ControlFlowReachabilityConfiguration {
2926
2933
scope = e2 and
2927
2934
isSuccessor = true
2928
2935
or
2929
- e1 . ( LocalFunctionAccess ) . getParent ( ) = e2 . ( LocalFunctionCall ) and
2936
+ isLocalFunctionCallReceiver ( e2 , e1 , _ ) and
2930
2937
exactScope = false and
2931
2938
scope = e2 and
2932
2939
isSuccessor = true
0 commit comments