mirror of
https://github.com/github/codeql.git
synced 2025-12-22 19:56:32 +01:00
C++: Let 'hasConstantBound' determine a reason.
This commit is contained in:
@@ -74,8 +74,9 @@ module CppLangImplConstant implements LangSig<FloatDelta> {
|
|||||||
/**
|
/**
|
||||||
* Holds if `e >= bound` (if `upper = false`) or `e <= bound` (if `upper = true`).
|
* Holds if `e >= bound` (if `upper = false`) or `e <= bound` (if `upper = true`).
|
||||||
*/
|
*/
|
||||||
predicate hasConstantBound(SemExpr e, float bound, boolean upper) {
|
predicate hasConstantBound(SemExpr e, float bound, boolean upper, SemReason reason) {
|
||||||
semHasConstantBoundConstantSpecific(e, bound, upper)
|
semHasConstantBoundConstantSpecific(e, bound, upper) and
|
||||||
|
reason instanceof SemTypeReason
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ module CppLangImplRelative implements LangSig<FloatDelta> {
|
|||||||
/**
|
/**
|
||||||
* Holds if `e >= bound` (if `upper = false`) or `e <= bound` (if `upper = true`).
|
* Holds if `e >= bound` (if `upper = false`) or `e <= bound` (if `upper = true`).
|
||||||
*/
|
*/
|
||||||
predicate hasConstantBound(SemExpr e, float bound, boolean upper) { none() }
|
predicate hasConstantBound(SemExpr e, float bound, boolean upper, SemReason reason) { none() }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds if `e >= bound + delta` (if `upper = false`) or `e <= bound + delta` (if `upper = true`).
|
* Holds if `e >= bound + delta` (if `upper = false`) or `e <= bound + delta` (if `upper = true`).
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ signature module LangSig<DeltaSig D> {
|
|||||||
/**
|
/**
|
||||||
* Holds if `e >= bound` (if `upper = false`) or `e <= bound` (if `upper = true`).
|
* Holds if `e >= bound` (if `upper = false`) or `e <= bound` (if `upper = true`).
|
||||||
*/
|
*/
|
||||||
predicate hasConstantBound(SemExpr e, D::Delta bound, boolean upper);
|
predicate hasConstantBound(SemExpr e, D::Delta bound, boolean upper, SemReason reason);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds if `e >= bound + delta` (if `upper = false`) or `e <= bound + delta` (if `upper = true`).
|
* Holds if `e >= bound + delta` (if `upper = false`) or `e <= bound + delta` (if `upper = true`).
|
||||||
@@ -920,14 +920,15 @@ module RangeStage<
|
|||||||
* Holds if `e` has an upper (for `upper = true`) or lower
|
* Holds if `e` has an upper (for `upper = true`) or lower
|
||||||
* (for `upper = false`) bound of `b`.
|
* (for `upper = false`) bound of `b`.
|
||||||
*/
|
*/
|
||||||
private predicate baseBound(SemExpr e, D::Delta b, boolean upper) {
|
private predicate baseBound(SemExpr e, D::Delta b, boolean upper, SemReason reason) {
|
||||||
hasConstantBound(e, b, upper)
|
hasConstantBound(e, b, upper, reason)
|
||||||
or
|
or
|
||||||
upper = false and
|
upper = false and
|
||||||
b = D::fromInt(0) and
|
b = D::fromInt(0) and
|
||||||
semPositive(e.(SemBitAndExpr).getAnOperand()) and
|
semPositive(e.(SemBitAndExpr).getAnOperand()) and
|
||||||
// REVIEW: We let the language opt out here to preserve original results.
|
// REVIEW: We let the language opt out here to preserve original results.
|
||||||
not ignoreZeroLowerBound(e)
|
not ignoreZeroLowerBound(e) and
|
||||||
|
reason instanceof SemNoReason
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1055,11 +1056,10 @@ module RangeStage<
|
|||||||
origdelta = delta and
|
origdelta = delta and
|
||||||
reason instanceof SemNoReason
|
reason instanceof SemNoReason
|
||||||
or
|
or
|
||||||
baseBound(e, delta, upper) and
|
baseBound(e, delta, upper, reason) and
|
||||||
b instanceof SemZeroBound and
|
b instanceof SemZeroBound and
|
||||||
fromBackEdge = false and
|
fromBackEdge = false and
|
||||||
origdelta = delta and
|
origdelta = delta
|
||||||
reason instanceof SemNoReason
|
|
||||||
or
|
or
|
||||||
exists(SemSsaVariable v, SemSsaReadPositionBlock bb |
|
exists(SemSsaVariable v, SemSsaReadPositionBlock bb |
|
||||||
boundedSsa(v, bb, b, delta, upper, fromBackEdge, origdelta, reason) and
|
boundedSsa(v, bb, b, delta, upper, fromBackEdge, origdelta, reason) and
|
||||||
|
|||||||
Reference in New Issue
Block a user