|
Lines 43-49
Link Here
|
| 43 |
VariableBinding finalVariables[]; |
43 |
VariableBinding finalVariables[]; |
| 44 |
int assignCount = 0; |
44 |
int assignCount = 0; |
| 45 |
|
45 |
|
| 46 |
LocalVariableBinding[] nullLocals; |
46 |
VariableBinding[] nullVariables; |
| 47 |
Expression[] nullReferences; |
47 |
Expression[] nullReferences; |
| 48 |
int[] nullCheckTypes; |
48 |
int[] nullCheckTypes; |
| 49 |
int nullCount; |
49 |
int nullCount; |
|
Lines 139-145
Link Here
|
| 139 |
if ((this.tagBits & FlowContext.DEFER_NULL_DIAGNOSTIC) != 0) { |
139 |
if ((this.tagBits & FlowContext.DEFER_NULL_DIAGNOSTIC) != 0) { |
| 140 |
// check only immutable null checks on innermost looping context |
140 |
// check only immutable null checks on innermost looping context |
| 141 |
for (int i = 0; i < this.nullCount; i++) { |
141 |
for (int i = 0; i < this.nullCount; i++) { |
| 142 |
LocalVariableBinding local = this.nullLocals[i]; |
142 |
VariableBinding local = this.nullVariables[i]; |
| 143 |
Expression expression = this.nullReferences[i]; |
143 |
Expression expression = this.nullReferences[i]; |
| 144 |
// final local variable |
144 |
// final local variable |
| 145 |
switch (this.nullCheckTypes[i]) { |
145 |
switch (this.nullCheckTypes[i]) { |
|
Lines 149-159
Link Here
|
| 149 |
this.nullReferences[i] = null; |
149 |
this.nullReferences[i] = null; |
| 150 |
if (this.nullCheckTypes[i] == (CAN_ONLY_NON_NULL | IN_COMPARISON_NON_NULL)) { |
150 |
if (this.nullCheckTypes[i] == (CAN_ONLY_NON_NULL | IN_COMPARISON_NON_NULL)) { |
| 151 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
151 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
| 152 |
scope.problemReporter().localVariableRedundantCheckOnNonNull(local, expression); |
152 |
scope.problemReporter().variableRedundantCheckOnNonNull(local, expression); |
| 153 |
} |
153 |
} |
| 154 |
} else { |
154 |
} else { |
| 155 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
155 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
| 156 |
scope.problemReporter().localVariableNonNullComparedToNull(local, expression); |
156 |
scope.problemReporter().variableNonNullComparedToNull(local, expression); |
| 157 |
} |
157 |
} |
| 158 |
} |
158 |
} |
| 159 |
continue; |
159 |
continue; |
|
Lines 165-175
Link Here
|
| 165 |
this.nullReferences[i] = null; |
165 |
this.nullReferences[i] = null; |
| 166 |
if (this.nullCheckTypes[i] == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL)) { |
166 |
if (this.nullCheckTypes[i] == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL)) { |
| 167 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
167 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
| 168 |
scope.problemReporter().localVariableRedundantCheckOnNonNull(local, expression); |
168 |
scope.problemReporter().variableRedundantCheckOnNonNull(local, expression); |
| 169 |
} |
169 |
} |
| 170 |
} else { |
170 |
} else { |
| 171 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
171 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
| 172 |
scope.problemReporter().localVariableNonNullComparedToNull(local, expression); |
172 |
scope.problemReporter().variableNonNullComparedToNull(local, expression); |
| 173 |
} |
173 |
} |
| 174 |
} |
174 |
} |
| 175 |
continue; |
175 |
continue; |
|
Lines 178-188
Link Here
|
| 178 |
this.nullReferences[i] = null; |
178 |
this.nullReferences[i] = null; |
| 179 |
if (this.nullCheckTypes[i] == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NULL)) { |
179 |
if (this.nullCheckTypes[i] == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NULL)) { |
| 180 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
180 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
| 181 |
scope.problemReporter().localVariableRedundantCheckOnNull(local, expression); |
181 |
scope.problemReporter().variableRedundantCheckOnNull(local, expression); |
| 182 |
} |
182 |
} |
| 183 |
} else { |
183 |
} else { |
| 184 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
184 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
| 185 |
scope.problemReporter().localVariableNullComparedToNonNull(local, expression); |
185 |
scope.problemReporter().variableNullComparedToNonNull(local, expression); |
| 186 |
} |
186 |
} |
| 187 |
} |
187 |
} |
| 188 |
continue; |
188 |
continue; |
|
Lines 197-223
Link Here
|
| 197 |
switch(this.nullCheckTypes[i] & CONTEXT_MASK) { |
197 |
switch(this.nullCheckTypes[i] & CONTEXT_MASK) { |
| 198 |
case FlowContext.IN_COMPARISON_NULL: |
198 |
case FlowContext.IN_COMPARISON_NULL: |
| 199 |
if (((this.nullCheckTypes[i] & CHECK_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
199 |
if (((this.nullCheckTypes[i] & CHECK_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
| 200 |
scope.problemReporter().localVariableNullReference(local, expression); |
200 |
scope.problemReporter().variableNullReference(local, expression); |
| 201 |
continue; |
201 |
continue; |
| 202 |
} |
202 |
} |
| 203 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
203 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
| 204 |
scope.problemReporter().localVariableRedundantCheckOnNull(local, expression); |
204 |
scope.problemReporter().variableRedundantCheckOnNull(local, expression); |
| 205 |
} |
205 |
} |
| 206 |
continue; |
206 |
continue; |
| 207 |
case FlowContext.IN_COMPARISON_NON_NULL: |
207 |
case FlowContext.IN_COMPARISON_NON_NULL: |
| 208 |
if (((this.nullCheckTypes[i] & CHECK_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
208 |
if (((this.nullCheckTypes[i] & CHECK_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
| 209 |
scope.problemReporter().localVariableNullReference(local, expression); |
209 |
scope.problemReporter().variableNullReference(local, expression); |
| 210 |
continue; |
210 |
continue; |
| 211 |
} |
211 |
} |
| 212 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
212 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
| 213 |
scope.problemReporter().localVariableNullComparedToNonNull(local, expression); |
213 |
scope.problemReporter().variableNullComparedToNonNull(local, expression); |
| 214 |
} |
214 |
} |
| 215 |
continue; |
215 |
continue; |
| 216 |
case FlowContext.IN_ASSIGNMENT: |
216 |
case FlowContext.IN_ASSIGNMENT: |
| 217 |
scope.problemReporter().localVariableRedundantNullAssignment(local, expression); |
217 |
scope.problemReporter().variableRedundantNullAssignment(local, expression); |
| 218 |
continue; |
218 |
continue; |
| 219 |
case FlowContext.IN_INSTANCEOF: |
219 |
case FlowContext.IN_INSTANCEOF: |
| 220 |
scope.problemReporter().localVariableNullInstanceof(local, expression); |
220 |
scope.problemReporter().variableNullInstanceof(local, expression); |
| 221 |
continue; |
221 |
continue; |
| 222 |
} |
222 |
} |
| 223 |
} else if (flowInfo.isPotentiallyNull(local)) { |
223 |
} else if (flowInfo.isPotentiallyNull(local)) { |
|
Lines 225-238
Link Here
|
| 225 |
case FlowContext.IN_COMPARISON_NULL: |
225 |
case FlowContext.IN_COMPARISON_NULL: |
| 226 |
this.nullReferences[i] = null; |
226 |
this.nullReferences[i] = null; |
| 227 |
if (((this.nullCheckTypes[i] & CHECK_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
227 |
if (((this.nullCheckTypes[i] & CHECK_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
| 228 |
scope.problemReporter().localVariablePotentialNullReference(local, expression); |
228 |
scope.problemReporter().variablePotentialNullReference(local, expression); |
| 229 |
continue; |
229 |
continue; |
| 230 |
} |
230 |
} |
| 231 |
break; |
231 |
break; |
| 232 |
case FlowContext.IN_COMPARISON_NON_NULL: |
232 |
case FlowContext.IN_COMPARISON_NON_NULL: |
| 233 |
this.nullReferences[i] = null; |
233 |
this.nullReferences[i] = null; |
| 234 |
if (((this.nullCheckTypes[i] & CHECK_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
234 |
if (((this.nullCheckTypes[i] & CHECK_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
| 235 |
scope.problemReporter().localVariablePotentialNullReference(local, expression); |
235 |
scope.problemReporter().variablePotentialNullReference(local, expression); |
| 236 |
continue; |
236 |
continue; |
| 237 |
} |
237 |
} |
| 238 |
break; |
238 |
break; |
|
Lines 242-248
Link Here
|
| 242 |
case MAY_NULL: |
242 |
case MAY_NULL: |
| 243 |
if (flowInfo.isDefinitelyNull(local)) { |
243 |
if (flowInfo.isDefinitelyNull(local)) { |
| 244 |
this.nullReferences[i] = null; |
244 |
this.nullReferences[i] = null; |
| 245 |
scope.problemReporter().localVariableNullReference(local, expression); |
245 |
scope.problemReporter().variableNullReference(local, expression); |
| 246 |
continue; |
246 |
continue; |
| 247 |
} |
247 |
} |
| 248 |
break; |
248 |
break; |
|
Lines 258-264
Link Here
|
| 258 |
for (int i = 0; i < this.nullCount; i++) { |
258 |
for (int i = 0; i < this.nullCount; i++) { |
| 259 |
Expression expression = this.nullReferences[i]; |
259 |
Expression expression = this.nullReferences[i]; |
| 260 |
// final local variable |
260 |
// final local variable |
| 261 |
LocalVariableBinding local = this.nullLocals[i]; |
261 |
VariableBinding local = this.nullVariables[i]; |
| 262 |
switch (this.nullCheckTypes[i]) { |
262 |
switch (this.nullCheckTypes[i]) { |
| 263 |
case CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NULL: |
263 |
case CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NULL: |
| 264 |
case CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL: |
264 |
case CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL: |
|
Lines 266-276
Link Here
|
| 266 |
this.nullReferences[i] = null; |
266 |
this.nullReferences[i] = null; |
| 267 |
if (this.nullCheckTypes[i] == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL)) { |
267 |
if (this.nullCheckTypes[i] == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL)) { |
| 268 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
268 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
| 269 |
scope.problemReporter().localVariableRedundantCheckOnNonNull(local, expression); |
269 |
scope.problemReporter().variableRedundantCheckOnNonNull(local, expression); |
| 270 |
} |
270 |
} |
| 271 |
} else { |
271 |
} else { |
| 272 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
272 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
| 273 |
scope.problemReporter().localVariableNonNullComparedToNull(local, expression); |
273 |
scope.problemReporter().variableNonNullComparedToNull(local, expression); |
| 274 |
} |
274 |
} |
| 275 |
} |
275 |
} |
| 276 |
continue; |
276 |
continue; |
|
Lines 285-311
Link Here
|
| 285 |
switch(this.nullCheckTypes[i] & CONTEXT_MASK) { |
285 |
switch(this.nullCheckTypes[i] & CONTEXT_MASK) { |
| 286 |
case FlowContext.IN_COMPARISON_NULL: |
286 |
case FlowContext.IN_COMPARISON_NULL: |
| 287 |
if (((this.nullCheckTypes[i] & CHECK_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
287 |
if (((this.nullCheckTypes[i] & CHECK_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
| 288 |
scope.problemReporter().localVariableNullReference(local, expression); |
288 |
scope.problemReporter().variableNullReference(local, expression); |
| 289 |
continue; |
289 |
continue; |
| 290 |
} |
290 |
} |
| 291 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
291 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
| 292 |
scope.problemReporter().localVariableRedundantCheckOnNull(local, expression); |
292 |
scope.problemReporter().variableRedundantCheckOnNull(local, expression); |
| 293 |
} |
293 |
} |
| 294 |
continue; |
294 |
continue; |
| 295 |
case FlowContext.IN_COMPARISON_NON_NULL: |
295 |
case FlowContext.IN_COMPARISON_NON_NULL: |
| 296 |
if (((this.nullCheckTypes[i] & CHECK_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
296 |
if (((this.nullCheckTypes[i] & CHECK_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
| 297 |
scope.problemReporter().localVariableNullReference(local, expression); |
297 |
scope.problemReporter().variableNullReference(local, expression); |
| 298 |
continue; |
298 |
continue; |
| 299 |
} |
299 |
} |
| 300 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
300 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
| 301 |
scope.problemReporter().localVariableNullComparedToNonNull(local, expression); |
301 |
scope.problemReporter().variableNullComparedToNonNull(local, expression); |
| 302 |
} |
302 |
} |
| 303 |
continue; |
303 |
continue; |
| 304 |
case FlowContext.IN_ASSIGNMENT: |
304 |
case FlowContext.IN_ASSIGNMENT: |
| 305 |
scope.problemReporter().localVariableRedundantNullAssignment(local, expression); |
305 |
scope.problemReporter().variableRedundantNullAssignment(local, expression); |
| 306 |
continue; |
306 |
continue; |
| 307 |
case FlowContext.IN_INSTANCEOF: |
307 |
case FlowContext.IN_INSTANCEOF: |
| 308 |
scope.problemReporter().localVariableNullInstanceof(local, expression); |
308 |
scope.problemReporter().variableNullInstanceof(local, expression); |
| 309 |
continue; |
309 |
continue; |
| 310 |
} |
310 |
} |
| 311 |
} else if (flowInfo.isPotentiallyNull(local)) { |
311 |
} else if (flowInfo.isPotentiallyNull(local)) { |
|
Lines 313-326
Link Here
|
| 313 |
case FlowContext.IN_COMPARISON_NULL: |
313 |
case FlowContext.IN_COMPARISON_NULL: |
| 314 |
this.nullReferences[i] = null; |
314 |
this.nullReferences[i] = null; |
| 315 |
if (((this.nullCheckTypes[i] & CHECK_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
315 |
if (((this.nullCheckTypes[i] & CHECK_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
| 316 |
scope.problemReporter().localVariablePotentialNullReference(local, expression); |
316 |
scope.problemReporter().variablePotentialNullReference(local, expression); |
| 317 |
continue; |
317 |
continue; |
| 318 |
} |
318 |
} |
| 319 |
break; |
319 |
break; |
| 320 |
case FlowContext.IN_COMPARISON_NON_NULL: |
320 |
case FlowContext.IN_COMPARISON_NON_NULL: |
| 321 |
this.nullReferences[i] = null; |
321 |
this.nullReferences[i] = null; |
| 322 |
if (((this.nullCheckTypes[i] & CHECK_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
322 |
if (((this.nullCheckTypes[i] & CHECK_MASK) == CAN_ONLY_NULL) && (expression.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
| 323 |
scope.problemReporter().localVariablePotentialNullReference(local, expression); |
323 |
scope.problemReporter().variablePotentialNullReference(local, expression); |
| 324 |
continue; |
324 |
continue; |
| 325 |
} |
325 |
} |
| 326 |
break; |
326 |
break; |
|
Lines 330-341
Link Here
|
| 330 |
case MAY_NULL: |
330 |
case MAY_NULL: |
| 331 |
if (flowInfo.isDefinitelyNull(local)) { |
331 |
if (flowInfo.isDefinitelyNull(local)) { |
| 332 |
this.nullReferences[i] = null; |
332 |
this.nullReferences[i] = null; |
| 333 |
scope.problemReporter().localVariableNullReference(local, expression); |
333 |
scope.problemReporter().variableNullReference(local, expression); |
| 334 |
continue; |
334 |
continue; |
| 335 |
} |
335 |
} |
| 336 |
if (flowInfo.isPotentiallyNull(local)) { |
336 |
if (flowInfo.isPotentiallyNull(local)) { |
| 337 |
this.nullReferences[i] = null; |
337 |
this.nullReferences[i] = null; |
| 338 |
scope.problemReporter().localVariablePotentialNullReference(local, expression); |
338 |
scope.problemReporter().variablePotentialNullReference(local, expression); |
| 339 |
continue; |
339 |
continue; |
| 340 |
} |
340 |
} |
| 341 |
break; |
341 |
break; |
|
Lines 460-486
Link Here
|
| 460 |
return true; |
460 |
return true; |
| 461 |
} |
461 |
} |
| 462 |
|
462 |
|
| 463 |
protected void recordNullReference(LocalVariableBinding local, |
463 |
protected void recordNullReference(VariableBinding local, |
| 464 |
Expression expression, int status) { |
464 |
Expression expression, int status) { |
| 465 |
if (this.nullCount == 0) { |
465 |
if (this.nullCount == 0) { |
| 466 |
this.nullLocals = new LocalVariableBinding[5]; |
466 |
this.nullVariables = new VariableBinding[5]; |
| 467 |
this.nullReferences = new Expression[5]; |
467 |
this.nullReferences = new Expression[5]; |
| 468 |
this.nullCheckTypes = new int[5]; |
468 |
this.nullCheckTypes = new int[5]; |
| 469 |
} |
469 |
} |
| 470 |
else if (this.nullCount == this.nullLocals.length) { |
470 |
else if (this.nullCount == this.nullVariables.length) { |
| 471 |
System.arraycopy(this.nullLocals, 0, |
471 |
System.arraycopy(this.nullVariables, 0, |
| 472 |
this.nullLocals = new LocalVariableBinding[this.nullCount * 2], 0, this.nullCount); |
472 |
this.nullVariables = new VariableBinding[this.nullCount * 2], 0, this.nullCount); |
| 473 |
System.arraycopy(this.nullReferences, 0, |
473 |
System.arraycopy(this.nullReferences, 0, |
| 474 |
this.nullReferences = new Expression[this.nullCount * 2], 0, this.nullCount); |
474 |
this.nullReferences = new Expression[this.nullCount * 2], 0, this.nullCount); |
| 475 |
System.arraycopy(this.nullCheckTypes, 0, |
475 |
System.arraycopy(this.nullCheckTypes, 0, |
| 476 |
this.nullCheckTypes = new int[this.nullCount * 2], 0, this.nullCount); |
476 |
this.nullCheckTypes = new int[this.nullCount * 2], 0, this.nullCount); |
| 477 |
} |
477 |
} |
| 478 |
this.nullLocals[this.nullCount] = local; |
478 |
this.nullVariables[this.nullCount] = local; |
| 479 |
this.nullReferences[this.nullCount] = expression; |
479 |
this.nullReferences[this.nullCount] = expression; |
| 480 |
this.nullCheckTypes[this.nullCount++] = status; |
480 |
this.nullCheckTypes[this.nullCount++] = status; |
| 481 |
} |
481 |
} |
| 482 |
|
482 |
|
| 483 |
public void recordUsingNullReference(Scope scope, LocalVariableBinding local, |
483 |
public void recordUsingNullReference(Scope scope, VariableBinding local, |
| 484 |
Expression reference, int checkType, FlowInfo flowInfo) { |
484 |
Expression reference, int checkType, FlowInfo flowInfo) { |
| 485 |
if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) != 0 || |
485 |
if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) != 0 || |
| 486 |
flowInfo.isDefinitelyUnknown(local)) { |
486 |
flowInfo.isDefinitelyUnknown(local)) { |
|
Lines 492-505
Link Here
|
| 492 |
if (flowInfo.isDefinitelyNonNull(local)) { |
492 |
if (flowInfo.isDefinitelyNonNull(local)) { |
| 493 |
if (checkType == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL)) { |
493 |
if (checkType == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL)) { |
| 494 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
494 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
| 495 |
scope.problemReporter().localVariableRedundantCheckOnNonNull(local, reference); |
495 |
scope.problemReporter().variableRedundantCheckOnNonNull(local, reference); |
| 496 |
} |
496 |
} |
| 497 |
if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) { |
497 |
if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) { |
| 498 |
flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS); |
498 |
flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS); |
| 499 |
} |
499 |
} |
| 500 |
} else { |
500 |
} else { |
| 501 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
501 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
| 502 |
scope.problemReporter().localVariableNonNullComparedToNull(local, reference); |
502 |
scope.problemReporter().variableNonNullComparedToNull(local, reference); |
| 503 |
} |
503 |
} |
| 504 |
if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) { |
504 |
if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) { |
| 505 |
flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS); |
505 |
flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS); |
|
Lines 508-521
Link Here
|
| 508 |
} else if (flowInfo.isDefinitelyNull(local)) { |
508 |
} else if (flowInfo.isDefinitelyNull(local)) { |
| 509 |
if (checkType == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NULL)) { |
509 |
if (checkType == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NULL)) { |
| 510 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
510 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
| 511 |
scope.problemReporter().localVariableRedundantCheckOnNull(local, reference); |
511 |
scope.problemReporter().variableRedundantCheckOnNull(local, reference); |
| 512 |
} |
512 |
} |
| 513 |
if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) { |
513 |
if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) { |
| 514 |
flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS); |
514 |
flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS); |
| 515 |
} |
515 |
} |
| 516 |
} else { |
516 |
} else { |
| 517 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
517 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
| 518 |
scope.problemReporter().localVariableNullComparedToNonNull(local, reference); |
518 |
scope.problemReporter().variableNullComparedToNonNull(local, reference); |
| 519 |
} |
519 |
} |
| 520 |
if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) { |
520 |
if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) { |
| 521 |
flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS); |
521 |
flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS); |
|
Lines 559-569
Link Here
|
| 559 |
switch(checkType & CONTEXT_MASK) { |
559 |
switch(checkType & CONTEXT_MASK) { |
| 560 |
case FlowContext.IN_COMPARISON_NULL: |
560 |
case FlowContext.IN_COMPARISON_NULL: |
| 561 |
if (((checkType & CHECK_MASK) == CAN_ONLY_NULL) && (reference.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
561 |
if (((checkType & CHECK_MASK) == CAN_ONLY_NULL) && (reference.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
| 562 |
scope.problemReporter().localVariableNullReference(local, reference); |
562 |
scope.problemReporter().variableNullReference(local, reference); |
| 563 |
return; |
563 |
return; |
| 564 |
} |
564 |
} |
| 565 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
565 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
| 566 |
scope.problemReporter().localVariableRedundantCheckOnNull(local, reference); |
566 |
scope.problemReporter().variableRedundantCheckOnNull(local, reference); |
| 567 |
} |
567 |
} |
| 568 |
if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) { |
568 |
if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) { |
| 569 |
flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS); |
569 |
flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS); |
|
Lines 571-604
Link Here
|
| 571 |
return; |
571 |
return; |
| 572 |
case FlowContext.IN_COMPARISON_NON_NULL: |
572 |
case FlowContext.IN_COMPARISON_NON_NULL: |
| 573 |
if (((checkType & CHECK_MASK) == CAN_ONLY_NULL) && (reference.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
573 |
if (((checkType & CHECK_MASK) == CAN_ONLY_NULL) && (reference.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
| 574 |
scope.problemReporter().localVariableNullReference(local, reference); |
574 |
scope.problemReporter().variableNullReference(local, reference); |
| 575 |
return; |
575 |
return; |
| 576 |
} |
576 |
} |
| 577 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
577 |
if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { |
| 578 |
scope.problemReporter().localVariableNullComparedToNonNull(local, reference); |
578 |
scope.problemReporter().variableNullComparedToNonNull(local, reference); |
| 579 |
} |
579 |
} |
| 580 |
if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) { |
580 |
if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) { |
| 581 |
flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS); |
581 |
flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS); |
| 582 |
} |
582 |
} |
| 583 |
return; |
583 |
return; |
| 584 |
case FlowContext.IN_ASSIGNMENT: |
584 |
case FlowContext.IN_ASSIGNMENT: |
| 585 |
scope.problemReporter().localVariableRedundantNullAssignment(local, reference); |
585 |
scope.problemReporter().variableRedundantNullAssignment(local, reference); |
| 586 |
return; |
586 |
return; |
| 587 |
case FlowContext.IN_INSTANCEOF: |
587 |
case FlowContext.IN_INSTANCEOF: |
| 588 |
scope.problemReporter().localVariableNullInstanceof(local, reference); |
588 |
scope.problemReporter().variableNullInstanceof(local, reference); |
| 589 |
return; |
589 |
return; |
| 590 |
} |
590 |
} |
| 591 |
} else if (flowInfo.isPotentiallyNull(local)) { |
591 |
} else if (flowInfo.isPotentiallyNull(local)) { |
| 592 |
switch(checkType & CONTEXT_MASK) { |
592 |
switch(checkType & CONTEXT_MASK) { |
| 593 |
case FlowContext.IN_COMPARISON_NULL: |
593 |
case FlowContext.IN_COMPARISON_NULL: |
| 594 |
if (((checkType & CHECK_MASK) == CAN_ONLY_NULL) && (reference.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
594 |
if (((checkType & CHECK_MASK) == CAN_ONLY_NULL) && (reference.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
| 595 |
scope.problemReporter().localVariablePotentialNullReference(local, reference); |
595 |
scope.problemReporter().variablePotentialNullReference(local, reference); |
| 596 |
return; |
596 |
return; |
| 597 |
} |
597 |
} |
| 598 |
break; |
598 |
break; |
| 599 |
case FlowContext.IN_COMPARISON_NON_NULL: |
599 |
case FlowContext.IN_COMPARISON_NON_NULL: |
| 600 |
if (((checkType & CHECK_MASK) == CAN_ONLY_NULL) && (reference.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
600 |
if (((checkType & CHECK_MASK) == CAN_ONLY_NULL) && (reference.implicitConversion & TypeIds.UNBOXING) != 0) { // check for auto-unboxing first and report appropriate warning |
| 601 |
scope.problemReporter().localVariablePotentialNullReference(local, reference); |
601 |
scope.problemReporter().variablePotentialNullReference(local, reference); |
| 602 |
return; |
602 |
return; |
| 603 |
} |
603 |
} |
| 604 |
break; |
604 |
break; |
|
Lines 617-627
Link Here
|
| 617 |
return; |
617 |
return; |
| 618 |
} |
618 |
} |
| 619 |
if (flowInfo.isDefinitelyNull(local)) { |
619 |
if (flowInfo.isDefinitelyNull(local)) { |
| 620 |
scope.problemReporter().localVariableNullReference(local, reference); |
620 |
scope.problemReporter().variableNullReference(local, reference); |
| 621 |
return; |
621 |
return; |
| 622 |
} |
622 |
} |
| 623 |
if (flowInfo.isPotentiallyNull(local)) { |
623 |
if (flowInfo.isPotentiallyNull(local)) { |
| 624 |
scope.problemReporter().localVariablePotentialNullReference(local, reference); |
624 |
scope.problemReporter().variablePotentialNullReference(local, reference); |
| 625 |
return; |
625 |
return; |
| 626 |
} |
626 |
} |
| 627 |
recordNullReference(local, reference, checkType); |
627 |
recordNullReference(local, reference, checkType); |