@@ -62,6 +62,18 @@ predicate accessPathCostLimits(int apLimit, int tupleLimit) {
62
62
tupleLimit = 1000
63
63
}
64
64
65
+ /**
66
+ * Holds if `arg` is an argument of `call` with an argument position that matches
67
+ * parameter position `ppos`.
68
+ */
69
+ pragma [ noinline]
70
+ predicate argumentPositionMatch ( DataFlowCall call , ArgNode arg , ParameterPosition ppos ) {
71
+ exists ( ArgumentPosition apos |
72
+ arg .argumentOf ( call , apos ) and
73
+ parameterMatch ( ppos , apos )
74
+ )
75
+ }
76
+
65
77
/**
66
78
* Provides a simple data-flow analysis for resolving lambda calls. The analysis
67
79
* currently excludes read-steps, store-steps, and flow-through.
@@ -71,31 +83,27 @@ predicate accessPathCostLimits(int apLimit, int tupleLimit) {
71
83
* calls. For this reason, we cannot reuse the code from `DataFlowImpl.qll` directly.
72
84
*/
73
85
private module LambdaFlow {
74
- private predicate viableParamNonLambda ( DataFlowCall call , ArgumentPosition apos , ParamNode p ) {
75
- exists ( ParameterPosition ppos |
76
- p .isParameterOf ( viableCallable ( call ) , ppos ) and
77
- parameterMatch ( ppos , apos )
78
- )
86
+ pragma [ noinline]
87
+ private predicate viableParamNonLambda ( DataFlowCall call , ParameterPosition ppos , ParamNode p ) {
88
+ p .isParameterOf ( viableCallable ( call ) , ppos )
79
89
}
80
90
81
- private predicate viableParamLambda ( DataFlowCall call , ArgumentPosition apos , ParamNode p ) {
82
- exists ( ParameterPosition ppos |
83
- p .isParameterOf ( viableCallableLambda ( call , _) , ppos ) and
84
- parameterMatch ( ppos , apos )
85
- )
91
+ pragma [ noinline]
92
+ private predicate viableParamLambda ( DataFlowCall call , ParameterPosition ppos , ParamNode p ) {
93
+ p .isParameterOf ( viableCallableLambda ( call , _) , ppos )
86
94
}
87
95
88
96
private predicate viableParamArgNonLambda ( DataFlowCall call , ParamNode p , ArgNode arg ) {
89
- exists ( ArgumentPosition pos |
90
- viableParamNonLambda ( call , pos , p ) and
91
- arg . argumentOf ( call , pos )
97
+ exists ( ParameterPosition ppos |
98
+ viableParamNonLambda ( call , ppos , p ) and
99
+ argumentPositionMatch ( call , arg , ppos )
92
100
)
93
101
}
94
102
95
103
private predicate viableParamArgLambda ( DataFlowCall call , ParamNode p , ArgNode arg ) {
96
- exists ( ArgumentPosition pos |
97
- viableParamLambda ( call , pos , p ) and
98
- arg . argumentOf ( call , pos )
104
+ exists ( ParameterPosition ppos |
105
+ viableParamLambda ( call , ppos , p ) and
106
+ argumentPositionMatch ( call , arg , ppos )
99
107
)
100
108
}
101
109
0 commit comments