Skip to content

Commit fe487a1

Browse files
committed
C++: Respond to PR reviews.
1 parent 8021958 commit fe487a1

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

cpp/ql/lib/experimental/semmle/code/cpp/semantic/analysis/RangeAnalysisStage.qll

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,17 +1064,17 @@ module RangeStage<DeltaSig D, BoundSig<D> Bounds, LangSig<D> LangParam, UtilSig<
10641064
)
10651065
or
10661066
exists(
1067-
SemZeroBound bLeft, SemZeroBound bRight, D::Delta dLeft, D::Delta dRight, boolean fbeLeft,
1068-
boolean fbeRight, D::Delta odLeft, D::Delta odRight, SemReason rLeft, SemReason rRight
1067+
D::Delta dLeft, D::Delta dRight, boolean fbeLeft, boolean fbeRight, D::Delta odLeft,
1068+
D::Delta odRight, SemReason rLeft, SemReason rRight
10691069
|
1070-
boundedMulOperand(e, upper, bLeft, true, dLeft, fbeLeft, odLeft, rLeft) and
1071-
boundedMulOperand(e, upper, bRight, false, dRight, fbeRight, odRight, rRight) and
1070+
boundedMulOperand(e, upper, true, dLeft, fbeLeft, odLeft, rLeft) and
1071+
boundedMulOperand(e, upper, false, dRight, fbeRight, odRight, rRight) and
10721072
delta = D::fromFloat(D::toFloat(dLeft) * D::toFloat(dRight)) and
10731073
fromBackEdge = fbeLeft.booleanOr(fbeRight)
10741074
|
1075-
b = bLeft and origdelta = odLeft and reason = rLeft
1075+
b instanceof SemZeroBound and origdelta = odLeft and reason = rLeft
10761076
or
1077-
b = bRight and origdelta = odRight and reason = rRight
1077+
b instanceof SemZeroBound and origdelta = odRight and reason = rRight
10781078
)
10791079
)
10801080
}
@@ -1111,11 +1111,11 @@ module RangeStage<DeltaSig D, BoundSig<D> Bounds, LangSig<D> LangParam, UtilSig<
11111111
}
11121112

11131113
/**
1114-
* Define `cmp(true) = <=` and `cmp(false) >=`.
1114+
* Define `cmp(true) = <=` and `cmp(false) = >=`.
11151115
*
1116-
* Holds if `mul = left * right`, and in order to know if `mul cmp(upper) B + k` (for
1117-
* some `B` and `k`) we need to know that `left cmp(upperLeft) B1 + k1` and
1118-
* `right cmp(upperRight) B2 + k2` (for some `B1`, `B2`, `k1`, and `k2`).
1116+
* Holds if `mul = left * right`, and in order to know if `mul cmp(upper) Z + k` (for
1117+
* some `k`) we need to know that `left cmp(upperLeft) Z + k1` and
1118+
* `right cmp(upperRight) Z + k2` (for some `k1` and `k2`).
11191119
*/
11201120
pragma[nomagic]
11211121
private predicate boundedMulOperandCand(
@@ -1190,19 +1190,27 @@ module RangeStage<DeltaSig D, BoundSig<D> Bounds, LangSig<D> LangParam, UtilSig<
11901190
)
11911191
}
11921192

1193+
/**
1194+
* Holds if `isLeft = true` and `mul`'s left operand is bounded by `delta`,
1195+
* or if `isLeft = false` and `mul`'s right operand is bounded by `delta`.
1196+
*
1197+
* If `upper = true` the computed bound is an upper boud, and if `upper = false`
1198+
* the computed bound is a lower bound. The `fromBackEdge`, `origdelta`, `reason`
1199+
* triple are defined by the recursive call to `bounded`.
1200+
*/
11931201
pragma[nomagic]
11941202
private predicate boundedMulOperand(
1195-
SemMulExpr mul, boolean upper, SemZeroBound b, boolean isLeft, D::Delta delta,
1196-
boolean fromBackEdge, D::Delta origdelta, SemReason reason
1203+
SemMulExpr mul, boolean upper, boolean isLeft, D::Delta delta, boolean fromBackEdge,
1204+
D::Delta origdelta, SemReason reason
11971205
) {
11981206
exists(boolean upperLeft, boolean upperRight, SemExpr left, SemExpr right |
11991207
boundedMulOperandCand(mul, left, right, upper, upperLeft, upperRight)
12001208
|
12011209
isLeft = true and
1202-
bounded(left, b, delta, upperLeft, fromBackEdge, origdelta, reason)
1210+
bounded(left, any(SemZeroBound zb), delta, upperLeft, fromBackEdge, origdelta, reason)
12031211
or
12041212
isLeft = false and
1205-
bounded(right, b, delta, upperRight, fromBackEdge, origdelta, reason)
1213+
bounded(right, any(SemZeroBound zb), delta, upperRight, fromBackEdge, origdelta, reason)
12061214
)
12071215
}
12081216
}

0 commit comments

Comments
 (0)