@@ -120,7 +120,7 @@ class AnalyzedVarDef extends VarDef {
120
120
* due to the given `cause`.
121
121
*/
122
122
predicate isIncomplete ( DataFlow:: Incompleteness cause ) {
123
- this instanceof Parameter and cause = "call"
123
+ this instanceof Parameter and DataFlow :: valueNode ( this ) . ( AnalyzedValueNode ) . isIncomplete ( cause )
124
124
or
125
125
this instanceof ImportSpecifier and cause = "import"
126
126
or
@@ -140,48 +140,59 @@ class AnalyzedVarDef extends VarDef {
140
140
TopLevel getTopLevel ( ) { result = this .( ASTNode ) .getTopLevel ( ) }
141
141
}
142
142
143
- /**
144
- * Flow analysis for simple parameters of selected functions.
145
- */
146
- private class AnalyzedParameter extends AnalyzedVarDef , @vardecl {
147
- AnalyzedParameter ( ) {
148
- exists ( FunctionWithAnalyzedParameters f , int parmIdx | this = f .getParameter ( parmIdx ) |
149
- // we cannot track flow into rest parameters
150
- not this .( Parameter ) .isRestParameter ( )
151
- )
152
- }
143
+ private predicate isAnalyzedParameter ( Parameter p ) {
144
+ exists ( FunctionWithAnalyzedParameters f , int parmIdx | p = f .getParameter ( parmIdx ) |
145
+ // we cannot track flow into rest parameters
146
+ not p .( Parameter ) .isRestParameter ( )
147
+ )
148
+ }
153
149
154
- /** Gets the function this is a parameter of. */
155
- FunctionWithAnalyzedParameters getFunction ( ) { this = result . getAParameter ( ) }
150
+ private class AnalyzedParameter extends AnalyzedValueNode {
151
+ override Parameter astNode ;
156
152
157
- override DataFlow:: AnalyzedNode getRhs ( ) {
158
- getFunction ( ) .argumentPassing ( this , result .asExpr ( ) ) or
159
- result = AnalyzedVarDef .super .getRhs ( )
160
- }
153
+ AnalyzedParameter ( ) { isAnalyzedParameter ( astNode ) }
161
154
162
- override AbstractValue getAnRhsValue ( ) {
163
- result = AnalyzedVarDef .super .getAnRhsValue ( )
155
+ FunctionWithAnalyzedParameters getFunction ( ) { astNode = result .getAParameter ( ) }
156
+
157
+ override AbstractValue getALocalValue ( ) {
158
+ exists ( DataFlow:: AnalyzedNode pred |
159
+ getFunction ( ) .argumentPassing ( astNode , pred .asExpr ( ) ) and
160
+ result = pred .getALocalValue ( )
161
+ )
164
162
or
165
- not getFunction ( ) .mayReceiveArgument ( this ) and
163
+ not getFunction ( ) .mayReceiveArgument ( astNode ) and
166
164
result = TAbstractUndefined ( )
165
+ or
166
+ result = astNode .getDefault ( ) .analyze ( ) .getALocalValue ( )
167
167
}
168
168
169
169
override predicate isIncomplete ( DataFlow:: Incompleteness cause ) {
170
170
getFunction ( ) .isIncomplete ( cause )
171
171
or
172
- not getFunction ( ) .argumentPassing ( this , _) and
173
- getFunction ( ) .mayReceiveArgument ( this ) and
172
+ not getFunction ( ) .argumentPassing ( astNode , _) and
173
+ getFunction ( ) .mayReceiveArgument ( astNode ) and
174
174
cause = "call"
175
175
}
176
176
}
177
177
178
+ /**
179
+ * Flow analysis for simple parameters of selected functions.
180
+ */
181
+ private class AnalyzedParameterAsVarDef extends AnalyzedVarDef , @vardecl {
182
+ AnalyzedParameterAsVarDef ( ) { this instanceof Parameter }
183
+
184
+ override AbstractValue getAnRhsValue ( ) {
185
+ result = DataFlow:: valueNode ( this ) .( AnalyzedValueNode ) .getALocalValue ( )
186
+ }
187
+ }
188
+
178
189
/**
179
190
* Flow analysis for simple rest parameters.
180
191
*/
181
- private class AnalyzedRestParameter extends AnalyzedVarDef , @vardecl {
182
- AnalyzedRestParameter ( ) { this .( Parameter ) .isRestParameter ( ) }
192
+ private class AnalyzedRestParameter extends AnalyzedValueNode {
193
+ AnalyzedRestParameter ( ) { astNode .( Parameter ) .isRestParameter ( ) }
183
194
184
- override AbstractValue getAnRhsValue ( ) { result = TAbstractOtherObject ( ) }
195
+ override AbstractValue getALocalValue ( ) { result = TAbstractOtherObject ( ) }
185
196
186
197
override predicate isIncomplete ( DataFlow:: Incompleteness cause ) { none ( ) }
187
198
}
0 commit comments