Skip to content

Commit d1ea1af

Browse files
committed
C++: Make small trivial tweaks
1 parent 5709964 commit d1ea1af

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

cpp/ql/lib/semmle/code/cpp/rangeanalysis/RangeAnalysisUtils.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@ predicate relOpWithSwap(
118118
*
119119
* This allows for the relation to be either as written, or with its
120120
* arguments reversed; for example, if `rel` is `x < 5` then
121-
* `relOpWithSwapAndNegate(rel, x, 5, Lesser(), Strict(), true)`,
122-
* `relOpWithSwapAndNegate(rel, 5, x, Greater(), Strict(), true)`,
123-
* `relOpWithSwapAndNegate(rel, x, 5, Greater(), Nonstrict(), false)` and
124-
* `relOpWithSwapAndNegate(rel, 5, x, Lesser(), Nonstrict(), false)` hold.
121+
* - `relOpWithSwapAndNegate(rel, x, 5, Lesser(), Strict(), true)`,
122+
* - `relOpWithSwapAndNegate(rel, 5, x, Greater(), Strict(), true)`,
123+
* - `relOpWithSwapAndNegate(rel, x, 5, Greater(), Nonstrict(), false)` and
124+
* - `relOpWithSwapAndNegate(rel, 5, x, Lesser(), Nonstrict(), false)` hold.
125125
*/
126126
predicate relOpWithSwapAndNegate(
127127
RelationalOperation rel, Expr a, Expr b, RelationDirection dir, RelationStrictness strict,

cpp/ql/lib/semmle/code/cpp/rangeanalysis/SimpleRangeAnalysis.qll

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,7 +1213,7 @@ private float getLowerBoundsImpl(Expr expr) {
12131213
// equal to `min(-y + 1,y - 1)`.
12141214
exists(float childLB |
12151215
childLB = getFullyConvertedLowerBounds(remExpr.getAnOperand()) and
1216-
not childLB >= 0
1216+
childLB < 0
12171217
|
12181218
result = getFullyConvertedLowerBounds(remExpr.getRightOperand()) - 1
12191219
or
@@ -1425,8 +1425,7 @@ private float getUpperBoundsImpl(Expr expr) {
14251425
// adding `-rhsLB` to the set of upper bounds.
14261426
exists(float rhsLB |
14271427
rhsLB = getFullyConvertedLowerBounds(remExpr.getRightOperand()) and
1428-
not rhsLB >= 0
1429-
|
1428+
rhsLB < 0 and
14301429
result = -rhsLB + 1
14311430
)
14321431
)
@@ -1571,8 +1570,7 @@ private float getPhiLowerBounds(StackVariable v, RangeSsaDefinition phi) {
15711570
exists(VariableAccess access, Expr guard, boolean branch, float defLB, float guardLB |
15721571
phi.isGuardPhi(v, access, guard, branch) and
15731572
lowerBoundFromGuard(guard, access, guardLB, branch) and
1574-
defLB = getFullyConvertedLowerBounds(access)
1575-
|
1573+
defLB = getFullyConvertedLowerBounds(access) and
15761574
// Compute the maximum of `guardLB` and `defLB`.
15771575
if guardLB > defLB then result = guardLB else result = defLB
15781576
)
@@ -1596,8 +1594,7 @@ private float getPhiUpperBounds(StackVariable v, RangeSsaDefinition phi) {
15961594
exists(VariableAccess access, Expr guard, boolean branch, float defUB, float guardUB |
15971595
phi.isGuardPhi(v, access, guard, branch) and
15981596
upperBoundFromGuard(guard, access, guardUB, branch) and
1599-
defUB = getFullyConvertedUpperBounds(access)
1600-
|
1597+
defUB = getFullyConvertedUpperBounds(access) and
16011598
// Compute the minimum of `guardUB` and `defUB`.
16021599
if guardUB < defUB then result = guardUB else result = defUB
16031600
)
@@ -1761,8 +1758,7 @@ private predicate upperBoundFromGuard(Expr guard, VariableAccess v, float ub, bo
17611758
}
17621759

17631760
/**
1764-
* This predicate simplifies the results returned by
1765-
* `linearBoundFromGuard`.
1761+
* This predicate simplifies the results returned by `linearBoundFromGuard`.
17661762
*/
17671763
private predicate boundFromGuard(
17681764
Expr guard, VariableAccess v, float boundValue, boolean isLowerBound,

0 commit comments

Comments
 (0)