File tree Expand file tree Collapse file tree 1 file changed +5
-14
lines changed
cpp/ql/lib/semmle/code/cpp/controlflow Expand file tree Collapse file tree 1 file changed +5
-14
lines changed Original file line number Diff line number Diff line change @@ -251,20 +251,11 @@ private class GuardConditionFromNotExpr extends GuardConditionImpl {
251
251
IRGuardCondition ir ;
252
252
253
253
GuardConditionFromNotExpr ( ) {
254
- // When `!` is applied to an integer (such as `x`) the generated IR looks
255
- // like:
256
- // ```
257
- // r1(glval<int>) = VariableAddress[myInt] :
258
- // r2(int) = Load[x] : &:r1, m1_6
259
- // r3(int) = Constant[0] :
260
- // r4(bool) = CompareEQ : r2, r3
261
- // ```
262
- // And so the `IRGuardCondition` for an expression such as `if(!x)` is the
263
- // `CompareEQ` instruction. However, users often expect the `x` to also
264
- // be a guard condition. But from the perspective of the IR the `x` is just
265
- // the left-hand side of a comparison against 0 so it's not included as a
266
- // normal `IRGuardCondition`. So to align with user expectations we make
267
- // that `x` a `GuardCondition`.
254
+ // Users often expect the `x` in `!x` to also be a guard condition. But
255
+ // from the perspective of the IR the `x` is just the left-hand side of a
256
+ // comparison against 0 so it's not included as a normal
257
+ // `IRGuardCondition`. So to align with user expectations we make that `x`
258
+ // a `GuardCondition`.
268
259
exists ( NotExpr notExpr , Type t |
269
260
this = notExpr .getOperand ( ) and
270
261
t = this .getUnspecifiedType ( ) and
You can’t perform that action at this time.
0 commit comments