Skip to content

Commit 3af3a72

Browse files
committed
C++: Don't short-circuit negations in conditions.
1 parent 257d94b commit 3af3a72

File tree

2 files changed

+1
-27
lines changed

2 files changed

+1
-27
lines changed

cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedCondition.qll

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -77,24 +77,6 @@ class TranslatedParenthesisCondition extends TranslatedFlexibleCondition {
7777
}
7878
}
7979

80-
class TranslatedNotCondition extends TranslatedFlexibleCondition {
81-
override NotExpr expr;
82-
83-
override Instruction getChildTrueSuccessor(TranslatedCondition child) {
84-
child = this.getOperand() and
85-
result = this.getConditionContext().getChildFalseSuccessor(this)
86-
}
87-
88-
override Instruction getChildFalseSuccessor(TranslatedCondition child) {
89-
child = this.getOperand() and
90-
result = this.getConditionContext().getChildTrueSuccessor(this)
91-
}
92-
93-
override TranslatedCondition getOperand() {
94-
result = getTranslatedCondition(expr.getOperand().getFullyConverted())
95-
}
96-
}
97-
9880
abstract class TranslatedNativeCondition extends TranslatedCondition, TTranslatedNativeCondition {
9981
TranslatedNativeCondition() { this = TTranslatedNativeCondition(expr) }
10082

cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedElement.qll

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,7 @@ private predicate isNativeCondition(Expr expr) {
190190
* depending on context.
191191
*/
192192
private predicate isFlexibleCondition(Expr expr) {
193-
(
194-
expr instanceof ParenthesisExpr or
195-
expr instanceof NotExpr
196-
) and
193+
expr instanceof ParenthesisExpr and
197194
usedAsCondition(expr) and
198195
not isIRConstant(expr)
199196
}
@@ -218,11 +215,6 @@ private predicate usedAsCondition(Expr expr) {
218215
condExpr.getCondition().getFullyConverted() = expr and not condExpr.isTwoOperand()
219216
)
220217
or
221-
exists(NotExpr notExpr |
222-
notExpr.getOperand().getFullyConverted() = expr and
223-
usedAsCondition(notExpr)
224-
)
225-
or
226218
exists(ParenthesisExpr paren |
227219
paren.getExpr() = expr and
228220
usedAsCondition(paren)

0 commit comments

Comments
 (0)