@@ -1617,6 +1617,18 @@ private module SimpleRangeAnalysisCached {
16171617 defMightOverflowPositively ( def , v )
16181618 }
16191619
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+
16201632 /**
16211633 * Holds if the expression might overflow negatively. This predicate
16221634 * does not consider the possibility that the expression might overflow
@@ -1630,6 +1642,11 @@ private module SimpleRangeAnalysisCached {
16301642 // bound of `x`, so the standard logic (above) does not work for
16311643 // detecting whether it might overflow.
16321644 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 )
16331650 }
16341651
16351652 /**
@@ -1657,6 +1674,11 @@ private module SimpleRangeAnalysisCached {
16571674 // bound of `x`, so the standard logic (above) does not work for
16581675 // detecting whether it might overflow.
16591676 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 )
16601682 }
16611683
16621684 /**
0 commit comments