File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
cpp/common/src/codingstandards/cpp Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -193,21 +193,26 @@ class InterestingOverflowingOperation extends Operation {
193193 *
194194 * Only holds for unsigned expressions, as signed overflow/underflow are undefined behavior.
195195 */
196- predicate hasValidPostCheck ( ) {
196+ predicate hasValidPostCheck ( ) { exists ( getAValidPostCheck ( ) ) }
197+
198+ /**
199+ * Gets a correct validity check, `gc`, after this expression which may overflow.
200+ */
201+ GuardCondition getAValidPostCheck ( ) {
197202 this .getType ( ) .( IntegralType ) .isUnsigned ( ) and
198203 (
199204 exists ( RelationalOperation ro |
200205 DataFlow:: localExprFlow ( this , ro .getLesserOperand ( ) ) and
201206 globalValueNumber ( ro .getGreaterOperand ( ) ) = globalValueNumber ( this .getAnOperand ( ) ) and
202207 ( this instanceof AddExpr or this instanceof AssignAddExpr ) and
203- ro instanceof GuardCondition
208+ result = ro
204209 )
205210 or
206211 exists ( RelationalOperation ro |
207212 DataFlow:: localExprFlow ( this , ro .getGreaterOperand ( ) ) and
208213 globalValueNumber ( ro .getLesserOperand ( ) ) = globalValueNumber ( this .getAnOperand ( ) ) and
209214 ( this instanceof SubExpr or this instanceof AssignSubExpr ) and
210- ro instanceof GuardCondition
215+ result = ro
211216 )
212217 )
213218 }
You can’t perform that action at this time.
0 commit comments