Skip to content

Commit 979b05c

Browse files
committed
C++: Apply suggested fixes from review
1 parent 68d4240 commit 979b05c

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ private predicate isRecursiveExpr(Expr e) {
523523
*/
524524
private module BoundsEstimate {
525525
/**
526-
* Gets the limit beyond which we enable widening. I.e., if the estimated
526+
* Gets the limit beyond which we enable widening. That is, if the estimated
527527
* number of bounds exceeds this limit, we enable widening such that the limit
528528
* will not be reached.
529529
*/
@@ -738,15 +738,16 @@ private module BoundsEstimate {
738738
result = nrOfBoundsExpr(condExpr.getThen()) * nrOfBoundsExpr(condExpr.getElse())
739739
)
740740
or
741-
exists(BinaryArithmeticOperation binop |
741+
exists(BinaryOperation binop |
742742
e = binop and
743743
result = nrOfBoundsExpr(binop.getLeftOperand()) * nrOfBoundsExpr(binop.getRightOperand())
744744
|
745745
e instanceof MaxExpr or
746746
e instanceof MinExpr or
747747
e instanceof AddExpr or
748748
e instanceof SubExpr or
749-
e instanceof UnsignedMulExpr
749+
e instanceof UnsignedMulExpr or
750+
e instanceof UnsignedBitwiseAndExpr
750751
)
751752
or
752753
exists(AssignExpr assign | e = assign and result = nrOfBoundsExpr(assign.getRValue()))
@@ -771,7 +772,7 @@ private module BoundsEstimate {
771772
e = crementOp and result = nrOfBoundsExpr(crementOp.getOperand())
772773
)
773774
or
774-
exists(RemExpr remExpr | e = remExpr | result = nrOfBoundsExpr(remExpr.getLeftOperand()))
775+
exists(RemExpr remExpr | e = remExpr | result = nrOfBoundsExpr(remExpr.getRightOperand()))
775776
or
776777
exists(Conversion convExpr |
777778
e = convExpr and
@@ -787,9 +788,6 @@ private module BoundsEstimate {
787788
not exists(getValue(e).toFloat())
788789
)
789790
or
790-
e instanceof UnsignedBitwiseAndExpr and
791-
result = 1
792-
or
793791
exists(RShiftExpr rsExpr |
794792
e = rsExpr and
795793
exists(getValue(rsExpr.getRightOperand().getFullyConverted()).toInt()) and

0 commit comments

Comments
 (0)