@@ -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
@@ -1631,8 +1643,10 @@ private module SimpleRangeAnalysisCached {
1631
1643
// detecting whether it might overflow.
1632
1644
getLowerBoundsImpl ( expr .( PostfixDecrExpr ) ) = exprMinVal ( expr )
1633
1645
or
1634
- // Expressions we cannot analyze could potentially overflow
1635
- not analyzableExpr ( expr )
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 )
1636
1650
}
1637
1651
1638
1652
/**
@@ -1661,8 +1675,10 @@ private module SimpleRangeAnalysisCached {
1661
1675
// detecting whether it might overflow.
1662
1676
getUpperBoundsImpl ( expr .( PostfixIncrExpr ) ) = exprMaxVal ( expr )
1663
1677
or
1664
- // Expressions we cannot analyze could potentially overflow
1665
- not analyzableExpr ( expr )
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 )
1666
1682
}
1667
1683
1668
1684
/**
0 commit comments