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 {
193
193
*
194
194
* Only holds for unsigned expressions, as signed overflow/underflow are undefined behavior.
195
195
*/
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 ( ) {
197
202
this .getType ( ) .( IntegralType ) .isUnsigned ( ) and
198
203
(
199
204
exists ( RelationalOperation ro |
200
205
DataFlow:: localExprFlow ( this , ro .getLesserOperand ( ) ) and
201
206
globalValueNumber ( ro .getGreaterOperand ( ) ) = globalValueNumber ( this .getAnOperand ( ) ) and
202
207
( this instanceof AddExpr or this instanceof AssignAddExpr ) and
203
- ro instanceof GuardCondition
208
+ result = ro
204
209
)
205
210
or
206
211
exists ( RelationalOperation ro |
207
212
DataFlow:: localExprFlow ( this , ro .getGreaterOperand ( ) ) and
208
213
globalValueNumber ( ro .getLesserOperand ( ) ) = globalValueNumber ( this .getAnOperand ( ) ) and
209
214
( this instanceof SubExpr or this instanceof AssignSubExpr ) and
210
- ro instanceof GuardCondition
215
+ result = ro
211
216
)
212
217
)
213
218
}
You can’t perform that action at this time.
0 commit comments