@@ -37,19 +37,19 @@ predicate inForeachStmtBody(ForeachStmt loop, Element e) {
3737 )
3838}
3939
40- class LambdaDataFlowConfiguration extends DataFlow:: Configuration {
41- LambdaDataFlowConfiguration ( ) { this = "LambdaDataFlowConfiguration" }
40+ module LambdaDataFlowConfig implements DataFlow:: ConfigSig {
41+ predicate isSource ( DataFlow :: Node source ) { lambdaCapturesLoopVariable ( source . asExpr ( ) , _ , _ ) }
4242
43- override predicate isSource ( DataFlow:: Node source ) {
44- lambdaCapturesLoopVariable ( source .asExpr ( ) , _, _)
45- }
43+ predicate isSink ( DataFlow:: Node sink ) { exists ( getAssignmentTarget ( sink .asExpr ( ) ) ) }
44+ }
4645
47- override predicate isSink ( DataFlow:: Node sink ) { exists ( getAssignmentTarget ( sink .asExpr ( ) ) ) }
46+ module LambdaDataFlow {
47+ private import DataFlow:: Global< LambdaDataFlowConfig >
4848
4949 predicate capturesLoopVarAndIsStoredIn (
5050 AnonymousFunctionExpr lambda , Variable loopVar , Element storage
5151 ) {
52- exists ( DataFlow:: Node sink | this . hasFlow ( DataFlow:: exprNode ( lambda ) , sink ) |
52+ exists ( DataFlow:: Node sink | flow ( DataFlow:: exprNode ( lambda ) , sink ) |
5353 storage = getAssignmentTarget ( sink .asExpr ( ) )
5454 ) and
5555 exists ( ForeachStmt loop | lambdaCapturesLoopVariable ( lambda , loop , loopVar ) |
@@ -109,7 +109,7 @@ predicate declaredInsideLoop(ForeachStmt loop, LocalVariable v) {
109109 )
110110}
111111
112- from LambdaDataFlowConfiguration c , AnonymousFunctionExpr lambda , Variable loopVar , Element storage
113- where c . capturesLoopVarAndIsStoredIn ( lambda , loopVar , storage )
112+ from AnonymousFunctionExpr lambda , Variable loopVar , Element storage
113+ where LambdaDataFlow :: capturesLoopVarAndIsStoredIn ( lambda , loopVar , storage )
114114select lambda , "Function which may be stored in $@ captures variable $@." , storage ,
115115 storage .toString ( ) , loopVar , loopVar .getName ( )
0 commit comments