Java: Exclude loop conditions from overflow check heuristic.

This commit is contained in:
Anders Schack-Mulligen
2019-10-18 11:58:46 +02:00
parent 066a2f0d12
commit 27b8a46dac

View File

@@ -168,10 +168,14 @@ Expr increaseOrDecreaseOfVar(SsaVariable v) {
}
predicate overFlowTest(ComparisonExpr comp) {
exists(SsaVariable v | comp.hasOperands(increaseOrDecreaseOfVar(v), v.getAUse()))
or
comp.getLesserOperand() = overFlowCand() and
comp.getGreaterOperand().(IntegerLiteral).getIntValue() = 0
(
exists(SsaVariable v | comp.hasOperands(increaseOrDecreaseOfVar(v), v.getAUse()))
or
comp.getLesserOperand() = overFlowCand() and
comp.getGreaterOperand().(IntegerLiteral).getIntValue() = 0
) and
// exclude loop conditions as they are unlikely to be overflow tests
not comp.getEnclosingStmt() instanceof LoopStmt
}
predicate concurrentModificationTest(BinaryExpr test) {