DfaMemoryStateImpl: fix sentinel handling

This commit is contained in:
Tagir Valeev
2018-04-17 10:52:38 +07:00
parent a83cedc58a
commit 7253845d5f
2 changed files with 10 additions and 8 deletions
@@ -789,9 +789,15 @@ public class DfaMemoryStateImpl implements DfaMemoryState {
private boolean applyRelationCondition(@NotNull DfaRelationValue dfaRelation) {
DfaValue dfaLeft = dfaRelation.getLeftOperand();
DfaValue dfaRight = dfaRelation.getRightOperand();
if (dfaLeft instanceof DfaUnknownValue || dfaRight instanceof DfaUnknownValue) return true;
RelationType relationType = dfaRelation.getRelation();
DfaConstValue sentinel = getFactory().getConstFactory().getSentinel();
if (dfaLeft == sentinel || dfaRight == sentinel) {
assert relationType == RelationType.EQ || relationType == RelationType.NE;
return (dfaLeft == dfaRight) == (relationType == RelationType.EQ);
}
if (dfaLeft instanceof DfaUnknownValue || dfaRight instanceof DfaUnknownValue) return true;
LongRangeSet left = getValueFact(dfaLeft, DfaFactType.RANGE);
LongRangeSet right = getValueFact(dfaRight, DfaFactType.RANGE);
@@ -896,11 +902,6 @@ public class DfaMemoryStateImpl implements DfaMemoryState {
return !isNegated || (dfaLeft instanceof DfaVariableValue && ((DfaVariableValue)dfaLeft).containsCalls());
}
DfaConstValue sentinel = getFactory().getConstFactory().getSentinel();
if (dfaLeft == sentinel || dfaRight == sentinel) {
return isNegated;
}
if (isNull(dfaLeft) && isNotNull(dfaRight) || isNull(dfaRight) && isNotNull(dfaLeft)) {
return isNegated;
}
@@ -1114,7 +1115,7 @@ public class DfaMemoryStateImpl implements DfaMemoryState {
public <T> void forceVariableFact(@NotNull DfaVariableValue var, @NotNull DfaFactType<T> factType, @Nullable T value) {
if (isUnknownState(var)) return;
DfaVariableState state = getVariableState(var);
flushVariable(var);
removeEquivalenceRelations(var);
setVariableState(var, state.withFact(factType, value));
updateEqClassesByState(var);
}
@@ -126,7 +126,8 @@ public class StreamInlining {
boolean flatMap(List<String> list, List<List<String>> ll) {
System.out.println(ll.stream().flatMap(l -> l.stream()).count());
return list.stream().map(s -> s.isEmpty() ? null : s)
.flatMap(s -> Stream.of(s, s.<warning descr="Method invocation 'trim' may produce 'java.lang.NullPointerException'">trim</warning>()).filter(r -> r != null))
.flatMap(s -> Stream.of(s, s.<warning descr="Method invocation 'trim' may produce 'java.lang.NullPointerException'">trim</warning>())
.filter(r -> <warning descr="Condition 'r != null' is always 'true'">r != null</warning>))
.anyMatch(x -> <warning descr="Condition 'x == null' is always 'false'">x == null</warning>);
}