@@ -42,19 +42,27 @@ class InterestingBinaryOverflowingExpr extends BinaryArithmeticOperation {
42
42
)
43
43
}
44
44
45
- predicate hasPostCheck ( ) {
46
- exists ( RelationalOperation ro |
47
- DataFlow:: localExprFlow ( this , ro .getLesserOperand ( ) ) and
48
- globalValueNumber ( ro .getGreaterOperand ( ) ) = globalValueNumber ( this .getAnOperand ( ) ) and
49
- this instanceof AddExpr and
50
- ro instanceof GuardCondition
51
- )
52
- or
53
- exists ( RelationalOperation ro |
54
- DataFlow:: localExprFlow ( this , ro .getGreaterOperand ( ) ) and
55
- globalValueNumber ( ro .getLesserOperand ( ) ) = globalValueNumber ( this .getAnOperand ( ) ) and
56
- this instanceof SubExpr and
57
- ro instanceof GuardCondition
45
+ /**
46
+ * Holds if there is a correct validity check after this expression which may overflow.
47
+ *
48
+ * Only holds for unsigned expressions, as signed overflow/underflow are undefined behavior.
49
+ */
50
+ predicate hasValidPostCheck ( ) {
51
+ this .getType ( ) .( IntegralType ) .isUnsigned ( ) and
52
+ (
53
+ exists ( RelationalOperation ro |
54
+ DataFlow:: localExprFlow ( this , ro .getLesserOperand ( ) ) and
55
+ globalValueNumber ( ro .getGreaterOperand ( ) ) = globalValueNumber ( this .getAnOperand ( ) ) and
56
+ this instanceof AddExpr and
57
+ ro instanceof GuardCondition
58
+ )
59
+ or
60
+ exists ( RelationalOperation ro |
61
+ DataFlow:: localExprFlow ( this , ro .getGreaterOperand ( ) ) and
62
+ globalValueNumber ( ro .getLesserOperand ( ) ) = globalValueNumber ( this .getAnOperand ( ) ) and
63
+ this instanceof SubExpr and
64
+ ro instanceof GuardCondition
65
+ )
58
66
)
59
67
}
60
68
0 commit comments