@@ -1617,6 +1617,18 @@ private module SimpleRangeAnalysisCached {
1617
1617
defMightOverflowPositively ( def , v )
1618
1618
}
1619
1619
1620
+ /**
1621
+ * Holds if `e` is an expression where the concept of overflow makes sense.
1622
+ * This predicate is used to filter out some of the unanalyzable expressions
1623
+ * from `exprMightOverflowPositively` and `exprMightOverflowNegatively`.
1624
+ */
1625
+ pragma [ inline]
1626
+ private predicate exprThatCanOverflow ( Expr e ) {
1627
+ e instanceof UnaryArithmeticOperation or
1628
+ e instanceof BinaryArithmeticOperation or
1629
+ e instanceof LShiftExpr
1630
+ }
1631
+
1620
1632
/**
1621
1633
* Holds if the expression might overflow negatively. This predicate
1622
1634
* does not consider the possibility that the expression might overflow
@@ -1630,6 +1642,11 @@ private module SimpleRangeAnalysisCached {
1630
1642
// bound of `x`, so the standard logic (above) does not work for
1631
1643
// detecting whether it might overflow.
1632
1644
getLowerBoundsImpl ( expr .( PostfixDecrExpr ) ) = exprMinVal ( expr )
1645
+ or
1646
+ // We can't conclude that any unanalyzable expression might overflow. This
1647
+ // is because there are many expressions that the range analysis doesn't
1648
+ // handle, but where the concept of overflow doesn't make sense.
1649
+ exprThatCanOverflow ( expr ) and not analyzableExpr ( expr )
1633
1650
}
1634
1651
1635
1652
/**
@@ -1657,6 +1674,11 @@ private module SimpleRangeAnalysisCached {
1657
1674
// bound of `x`, so the standard logic (above) does not work for
1658
1675
// detecting whether it might overflow.
1659
1676
getUpperBoundsImpl ( expr .( PostfixIncrExpr ) ) = exprMaxVal ( expr )
1677
+ or
1678
+ // We can't conclude that any unanalyzable expression might overflow. This
1679
+ // is because there are many expressions that the range analysis doesn't
1680
+ // handle, but where the concept of overflow doesn't make sense.
1681
+ exprThatCanOverflow ( expr ) and not analyzableExpr ( expr )
1660
1682
}
1661
1683
1662
1684
/**
0 commit comments