mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Rangeanalysis: Refactor base bounds.
This commit is contained in:
@@ -995,15 +995,23 @@ module RangeStage<
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds if `e` has an upper (for `upper = true`) or lower
|
* Holds if `e` has an intrinsic upper (for `upper = true`) or lower
|
||||||
* (for `upper = false`) bound of `b`.
|
* (for `upper = false`) bound of `b + delta` as a base case for range analysis.
|
||||||
*/
|
*/
|
||||||
private predicate baseBound(Sem::Expr e, D::Delta b, boolean upper) {
|
private predicate baseBound(Sem::Expr e, SemBound b, D::Delta delta, boolean upper) {
|
||||||
hasConstantBound(e, b, upper)
|
includeBound(b) and
|
||||||
or
|
(
|
||||||
upper = false and
|
e = b.getExpr(delta) and
|
||||||
b = D::fromInt(0) and
|
upper = [true, false]
|
||||||
semPositive(e.(Sem::BitAndExpr).getAnOperand())
|
or
|
||||||
|
hasConstantBound(e, delta, upper) and
|
||||||
|
b instanceof SemZeroBound
|
||||||
|
or
|
||||||
|
upper = false and
|
||||||
|
delta = D::fromInt(0) and
|
||||||
|
semPositive(e.(Sem::BitAndExpr).getAnOperand()) and
|
||||||
|
b instanceof SemZeroBound
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1129,19 +1137,10 @@ module RangeStage<
|
|||||||
) {
|
) {
|
||||||
not ignoreExprBound(e) and
|
not ignoreExprBound(e) and
|
||||||
(
|
(
|
||||||
e = b.getExpr(delta) and
|
baseBound(e, b, delta, upper) and
|
||||||
(upper = true or upper = false) and
|
|
||||||
fromBackEdge = false and
|
fromBackEdge = false and
|
||||||
origdelta = delta and
|
origdelta = delta and
|
||||||
reason = TSemNoReason() and
|
reason = TSemNoReason()
|
||||||
includeBound(b)
|
|
||||||
or
|
|
||||||
baseBound(e, delta, upper) and
|
|
||||||
b instanceof SemZeroBound and
|
|
||||||
fromBackEdge = false and
|
|
||||||
origdelta = delta and
|
|
||||||
reason = TSemNoReason() and
|
|
||||||
includeBound(b)
|
|
||||||
or
|
or
|
||||||
exists(Sem::SsaVariable v, SsaReadPositionBlock bb |
|
exists(Sem::SsaVariable v, SsaReadPositionBlock bb |
|
||||||
boundedSsa(v, b, delta, bb, upper, fromBackEdge, origdelta, reason) and
|
boundedSsa(v, b, delta, bb, upper, fromBackEdge, origdelta, reason) and
|
||||||
|
|||||||
Reference in New Issue
Block a user