Lines 127-135
Link Here
|
127 |
if (flowInfo.isDefinitelyNonNull(local)) { |
127 |
if (flowInfo.isDefinitelyNonNull(local)) { |
128 |
this.nullReferences[i] = null; |
128 |
this.nullReferences[i] = null; |
129 |
if (this.nullCheckTypes[i] == (CAN_ONLY_NON_NULL | IN_COMPARISON_NON_NULL)) { |
129 |
if (this.nullCheckTypes[i] == (CAN_ONLY_NON_NULL | IN_COMPARISON_NON_NULL)) { |
130 |
scope.problemReporter().localVariableRedundantCheckOnNonNull(local, expression); |
130 |
if (!this.hideNullComparisonWarnings) { |
|
|
131 |
scope.problemReporter().localVariableRedundantCheckOnNonNull(local, expression); |
132 |
} |
131 |
} else { |
133 |
} else { |
132 |
scope.problemReporter().localVariableNonNullComparedToNull(local, expression); |
134 |
if (!this.hideNullComparisonWarnings) { |
|
|
135 |
scope.problemReporter().localVariableNonNullComparedToNull(local, expression); |
136 |
} |
133 |
} |
137 |
} |
134 |
continue; |
138 |
continue; |
135 |
} |
139 |
} |
Lines 139-156
Link Here
|
139 |
if (flowInfo.isDefinitelyNonNull(local)) { |
143 |
if (flowInfo.isDefinitelyNonNull(local)) { |
140 |
this.nullReferences[i] = null; |
144 |
this.nullReferences[i] = null; |
141 |
if (this.nullCheckTypes[i] == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL)) { |
145 |
if (this.nullCheckTypes[i] == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL)) { |
142 |
scope.problemReporter().localVariableRedundantCheckOnNonNull(local, expression); |
146 |
if (!this.hideNullComparisonWarnings) { |
|
|
147 |
scope.problemReporter().localVariableRedundantCheckOnNonNull(local, expression); |
148 |
} |
143 |
} else { |
149 |
} else { |
144 |
scope.problemReporter().localVariableNonNullComparedToNull(local, expression); |
150 |
if (!this.hideNullComparisonWarnings) { |
|
|
151 |
scope.problemReporter().localVariableNonNullComparedToNull(local, expression); |
152 |
} |
145 |
} |
153 |
} |
146 |
continue; |
154 |
continue; |
147 |
} |
155 |
} |
148 |
if (flowInfo.isDefinitelyNull(local)) { |
156 |
if (flowInfo.isDefinitelyNull(local)) { |
149 |
this.nullReferences[i] = null; |
157 |
this.nullReferences[i] = null; |
150 |
if (this.nullCheckTypes[i] == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NULL)) { |
158 |
if (this.nullCheckTypes[i] == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NULL)) { |
151 |
scope.problemReporter().localVariableRedundantCheckOnNull(local, expression); |
159 |
if (!this.hideNullComparisonWarnings) { |
|
|
160 |
scope.problemReporter().localVariableRedundantCheckOnNull(local, expression); |
161 |
} |
152 |
} else { |
162 |
} else { |
153 |
scope.problemReporter().localVariableNullComparedToNonNull(local, expression); |
163 |
if (!this.hideNullComparisonWarnings) { |
|
|
164 |
scope.problemReporter().localVariableNullComparedToNonNull(local, expression); |
165 |
} |
154 |
} |
166 |
} |
155 |
continue; |
167 |
continue; |
156 |
} |
168 |
} |
Lines 163-172
Link Here
|
163 |
this.nullReferences[i] = null; |
175 |
this.nullReferences[i] = null; |
164 |
switch(this.nullCheckTypes[i] & CONTEXT_MASK) { |
176 |
switch(this.nullCheckTypes[i] & CONTEXT_MASK) { |
165 |
case FlowContext.IN_COMPARISON_NULL: |
177 |
case FlowContext.IN_COMPARISON_NULL: |
166 |
scope.problemReporter().localVariableRedundantCheckOnNull(local, expression); |
178 |
if (!this.hideNullComparisonWarnings) { |
|
|
179 |
scope.problemReporter().localVariableRedundantCheckOnNull(local, expression); |
180 |
} |
167 |
continue; |
181 |
continue; |
168 |
case FlowContext.IN_COMPARISON_NON_NULL: |
182 |
case FlowContext.IN_COMPARISON_NON_NULL: |
169 |
scope.problemReporter().localVariableNullComparedToNonNull(local, expression); |
183 |
if (!this.hideNullComparisonWarnings) { |
|
|
184 |
scope.problemReporter().localVariableNullComparedToNonNull(local, expression); |
185 |
} |
170 |
continue; |
186 |
continue; |
171 |
case FlowContext.IN_ASSIGNMENT: |
187 |
case FlowContext.IN_ASSIGNMENT: |
172 |
scope.problemReporter().localVariableRedundantNullAssignment(local, expression); |
188 |
scope.problemReporter().localVariableRedundantNullAssignment(local, expression); |
Lines 203-211
Link Here
|
203 |
if (flowInfo.isDefinitelyNonNull(local)) { |
219 |
if (flowInfo.isDefinitelyNonNull(local)) { |
204 |
this.nullReferences[i] = null; |
220 |
this.nullReferences[i] = null; |
205 |
if (this.nullCheckTypes[i] == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL)) { |
221 |
if (this.nullCheckTypes[i] == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL)) { |
206 |
scope.problemReporter().localVariableRedundantCheckOnNonNull(local, expression); |
222 |
if (!this.hideNullComparisonWarnings) { |
|
|
223 |
scope.problemReporter().localVariableRedundantCheckOnNonNull(local, expression); |
224 |
} |
207 |
} else { |
225 |
} else { |
208 |
scope.problemReporter().localVariableNonNullComparedToNull(local, expression); |
226 |
if (!this.hideNullComparisonWarnings) { |
|
|
227 |
scope.problemReporter().localVariableNonNullComparedToNull(local, expression); |
228 |
} |
209 |
} |
229 |
} |
210 |
continue; |
230 |
continue; |
211 |
} |
231 |
} |
Lines 218-227
Link Here
|
218 |
this.nullReferences[i] = null; |
238 |
this.nullReferences[i] = null; |
219 |
switch(this.nullCheckTypes[i] & CONTEXT_MASK) { |
239 |
switch(this.nullCheckTypes[i] & CONTEXT_MASK) { |
220 |
case FlowContext.IN_COMPARISON_NULL: |
240 |
case FlowContext.IN_COMPARISON_NULL: |
221 |
scope.problemReporter().localVariableRedundantCheckOnNull(local, expression); |
241 |
if (!this.hideNullComparisonWarnings) { |
|
|
242 |
scope.problemReporter().localVariableRedundantCheckOnNull(local, expression); |
243 |
} |
222 |
continue; |
244 |
continue; |
223 |
case FlowContext.IN_COMPARISON_NON_NULL: |
245 |
case FlowContext.IN_COMPARISON_NON_NULL: |
224 |
scope.problemReporter().localVariableNullComparedToNonNull(local, expression); |
246 |
if (!this.hideNullComparisonWarnings) { |
|
|
247 |
scope.problemReporter().localVariableNullComparedToNonNull(local, expression); |
248 |
} |
225 |
continue; |
249 |
continue; |
226 |
case FlowContext.IN_ASSIGNMENT: |
250 |
case FlowContext.IN_ASSIGNMENT: |
227 |
scope.problemReporter().localVariableRedundantNullAssignment(local, expression); |
251 |
scope.problemReporter().localVariableRedundantNullAssignment(local, expression); |
Lines 395-422
Link Here
|
395 |
case CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL: |
419 |
case CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL: |
396 |
if (flowInfo.isDefinitelyNonNull(local)) { |
420 |
if (flowInfo.isDefinitelyNonNull(local)) { |
397 |
if (checkType == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL)) { |
421 |
if (checkType == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL)) { |
398 |
scope.problemReporter().localVariableRedundantCheckOnNonNull(local, reference); |
422 |
if (!this.hideNullComparisonWarnings) { |
|
|
423 |
scope.problemReporter().localVariableRedundantCheckOnNonNull(local, reference); |
424 |
} |
399 |
flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE); |
425 |
flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE); |
400 |
} else { |
426 |
} else { |
401 |
scope.problemReporter().localVariableNonNullComparedToNull(local, reference); |
427 |
if (!this.hideNullComparisonWarnings) { |
|
|
428 |
scope.problemReporter().localVariableNonNullComparedToNull(local, reference); |
429 |
} |
402 |
flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE); |
430 |
flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE); |
403 |
} |
431 |
} |
404 |
} else if (flowInfo.isDefinitelyNull(local)) { |
432 |
} else if (flowInfo.isDefinitelyNull(local)) { |
405 |
if (checkType == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NULL)) { |
433 |
if (checkType == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NULL)) { |
406 |
scope.problemReporter().localVariableRedundantCheckOnNull(local, reference); |
434 |
if (!this.hideNullComparisonWarnings) { |
|
|
435 |
scope.problemReporter().localVariableRedundantCheckOnNull(local, reference); |
436 |
} |
407 |
flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE); |
437 |
flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE); |
408 |
} else { |
438 |
} else { |
409 |
scope.problemReporter().localVariableNullComparedToNonNull(local, reference); |
439 |
if (!this.hideNullComparisonWarnings) { |
|
|
440 |
scope.problemReporter().localVariableNullComparedToNonNull(local, reference); |
441 |
} |
410 |
flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE); |
442 |
flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE); |
411 |
} |
443 |
} |
412 |
} else if (this.upstreamNullFlowInfo.isDefinitelyNonNull(local) && !flowInfo.isPotentiallyNull(local)) { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=291418 |
444 |
} else if (this.upstreamNullFlowInfo.isDefinitelyNonNull(local) && !flowInfo.isPotentiallyNull(local)) { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=291418 |
413 |
flowInfo.markAsDefinitelyNonNull(local); |
445 |
flowInfo.markAsDefinitelyNonNull(local); |
414 |
recordNullReference(local, reference, checkType); |
446 |
if (!this.hideNullComparisonWarnings) { |
|
|
447 |
recordNullReference(local, reference, checkType); |
448 |
} |
415 |
} else if (! flowInfo.cannotBeDefinitelyNullOrNonNull(local)) { |
449 |
} else if (! flowInfo.cannotBeDefinitelyNullOrNonNull(local)) { |
416 |
if (flowInfo.isPotentiallyNonNull(local)) { |
450 |
if (flowInfo.isPotentiallyNonNull(local)) { |
417 |
recordNullReference(local, reference, CAN_ONLY_NON_NULL | checkType & CONTEXT_MASK); |
451 |
recordNullReference(local, reference, CAN_ONLY_NON_NULL | checkType & CONTEXT_MASK); |
418 |
} else { |
452 |
} else { |
419 |
recordNullReference(local, reference, checkType); |
453 |
if (!this.hideNullComparisonWarnings) { |
|
|
454 |
recordNullReference(local, reference, checkType); |
455 |
} |
420 |
} |
456 |
} |
421 |
} |
457 |
} |
422 |
return; |
458 |
return; |
Lines 431-441
Link Here
|
431 |
if (flowInfo.isDefinitelyNull(local)) { |
467 |
if (flowInfo.isDefinitelyNull(local)) { |
432 |
switch(checkType & CONTEXT_MASK) { |
468 |
switch(checkType & CONTEXT_MASK) { |
433 |
case FlowContext.IN_COMPARISON_NULL: |
469 |
case FlowContext.IN_COMPARISON_NULL: |
434 |
scope.problemReporter().localVariableRedundantCheckOnNull(local, reference); |
470 |
if (!this.hideNullComparisonWarnings) { |
|
|
471 |
scope.problemReporter().localVariableRedundantCheckOnNull(local, reference); |
472 |
} |
435 |
flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE); |
473 |
flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE); |
436 |
return; |
474 |
return; |
437 |
case FlowContext.IN_COMPARISON_NON_NULL: |
475 |
case FlowContext.IN_COMPARISON_NON_NULL: |
438 |
scope.problemReporter().localVariableNullComparedToNonNull(local, reference); |
476 |
if (!this.hideNullComparisonWarnings) { |
|
|
477 |
scope.problemReporter().localVariableNullComparedToNonNull(local, reference); |
478 |
} |
439 |
flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE); |
479 |
flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE); |
440 |
return; |
480 |
return; |
441 |
case FlowContext.IN_ASSIGNMENT: |
481 |
case FlowContext.IN_ASSIGNMENT: |
Lines 446-452
Link Here
|
446 |
return; |
486 |
return; |
447 |
} |
487 |
} |
448 |
} |
488 |
} |
449 |
recordNullReference(local, reference, checkType); |
489 |
// if the contention is inside assert statement, we want to avoid null warnings only in case of |
|
|
490 |
// comparisons and not in case of assignment and instanceof |
491 |
if (!this.hideNullComparisonWarnings |
492 |
|| (checkType & CONTEXT_MASK) == FlowContext.IN_ASSIGNMENT |
493 |
|| (checkType & CONTEXT_MASK) == FlowContext.IN_INSTANCEOF) { |
494 |
recordNullReference(local, reference, checkType); |
495 |
} |
450 |
return; |
496 |
return; |
451 |
case MAY_NULL : |
497 |
case MAY_NULL : |
452 |
if (flowInfo.isDefinitelyNonNull(local)) { |
498 |
if (flowInfo.isDefinitelyNonNull(local)) { |