@@ -37,19 +37,19 @@ predicate inForeachStmtBody(ForeachStmt loop, Element e) {
37
37
)
38
38
}
39
39
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 ( ) , _ , _ ) }
42
42
43
- override predicate isSource ( DataFlow:: Node source ) {
44
- lambdaCapturesLoopVariable ( source .asExpr ( ) , _, _)
45
- }
43
+ predicate isSink ( DataFlow:: Node sink ) { exists ( getAssignmentTarget ( sink .asExpr ( ) ) ) }
44
+ }
46
45
47
- override predicate isSink ( DataFlow:: Node sink ) { exists ( getAssignmentTarget ( sink .asExpr ( ) ) ) }
46
+ module LambdaDataFlow {
47
+ private import DataFlow:: Global< LambdaDataFlowConfig >
48
48
49
49
predicate capturesLoopVarAndIsStoredIn (
50
50
AnonymousFunctionExpr lambda , Variable loopVar , Element storage
51
51
) {
52
- exists ( DataFlow:: Node sink | this . hasFlow ( DataFlow:: exprNode ( lambda ) , sink ) |
52
+ exists ( DataFlow:: Node sink | flow ( DataFlow:: exprNode ( lambda ) , sink ) |
53
53
storage = getAssignmentTarget ( sink .asExpr ( ) )
54
54
) and
55
55
exists ( ForeachStmt loop | lambdaCapturesLoopVariable ( lambda , loop , loopVar ) |
@@ -109,7 +109,7 @@ predicate declaredInsideLoop(ForeachStmt loop, LocalVariable v) {
109
109
)
110
110
}
111
111
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 )
114
114
select lambda , "Function which may be stored in $@ captures variable $@." , storage ,
115
115
storage .toString ( ) , loopVar , loopVar .getName ( )
0 commit comments