Skip to content

Commit b39a932

Browse files
committed
C++: Update comment in the char pred of 'GuardConditionFromNotExpr'.
1 parent d5b31eb commit b39a932

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

cpp/ql/lib/semmle/code/cpp/controlflow/IRGuards.qll

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -251,20 +251,11 @@ private class GuardConditionFromNotExpr extends GuardConditionImpl {
251251
IRGuardCondition ir;
252252

253253
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`.
268259
exists(NotExpr notExpr, Type t |
269260
this = notExpr.getOperand() and
270261
t = this.getUnspecifiedType() and

0 commit comments

Comments
 (0)