Skip to content

Commit 7364634

Browse files
committed
C++: No need to special-case negations in IRGuards.
1 parent 3af3a72 commit 7364634

File tree

1 file changed

+0
-38
lines changed

1 file changed

+0
-38
lines changed

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

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@ class GuardCondition extends Expr {
3030
or
3131
// no binary operators in the IR
3232
this.(BinaryLogicalOperation).getAnOperand() instanceof GuardCondition
33-
or
34-
// the IR short-circuits if(!x)
35-
// don't produce a guard condition for `y = !x` and other non-short-circuited cases
36-
not exists(Instruction inst | this.getFullyConverted() = inst.getAst()) and
37-
exists(IRGuardCondition ir | this.(NotExpr).getOperand() = ir.getAst())
3833
}
3934

4035
/**
@@ -140,39 +135,6 @@ private class GuardConditionFromBinaryLogicalOperator extends GuardCondition {
140135
}
141136
}
142137

143-
/**
144-
* A `!` operator in the AST that guards one or more basic blocks, and does not have a corresponding
145-
* IR instruction.
146-
*/
147-
private class GuardConditionFromShortCircuitNot extends GuardCondition, NotExpr {
148-
GuardConditionFromShortCircuitNot() {
149-
not exists(Instruction inst | this.getFullyConverted() = inst.getAst()) and
150-
exists(IRGuardCondition ir | this.getOperand() = ir.getAst())
151-
}
152-
153-
override predicate controls(BasicBlock controlled, boolean testIsTrue) {
154-
this.getOperand().(GuardCondition).controls(controlled, testIsTrue.booleanNot())
155-
}
156-
157-
override predicate comparesLt(Expr left, Expr right, int k, boolean isLessThan, boolean testIsTrue) {
158-
this.getOperand()
159-
.(GuardCondition)
160-
.comparesLt(left, right, k, isLessThan, testIsTrue.booleanNot())
161-
}
162-
163-
override predicate ensuresLt(Expr left, Expr right, int k, BasicBlock block, boolean isLessThan) {
164-
this.getOperand().(GuardCondition).ensuresLt(left, right, k, block, isLessThan.booleanNot())
165-
}
166-
167-
override predicate comparesEq(Expr left, Expr right, int k, boolean areEqual, boolean testIsTrue) {
168-
this.getOperand().(GuardCondition).comparesEq(left, right, k, areEqual, testIsTrue.booleanNot())
169-
}
170-
171-
override predicate ensuresEq(Expr left, Expr right, int k, BasicBlock block, boolean areEqual) {
172-
this.getOperand().(GuardCondition).ensuresEq(left, right, k, block, areEqual.booleanNot())
173-
}
174-
}
175-
176138
/**
177139
* A Boolean condition in the AST that guards one or more basic blocks and has a corresponding IR
178140
* instruction.

0 commit comments

Comments
 (0)