mirror of
https://github.com/github/codeql.git
synced 2025-12-22 11:46:32 +01:00
C++: Don't short-circuit negations in conditions.
This commit is contained in:
@@ -77,24 +77,6 @@ class TranslatedParenthesisCondition extends TranslatedFlexibleCondition {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class TranslatedNotCondition extends TranslatedFlexibleCondition {
|
|
||||||
override NotExpr expr;
|
|
||||||
|
|
||||||
override Instruction getChildTrueSuccessor(TranslatedCondition child) {
|
|
||||||
child = this.getOperand() and
|
|
||||||
result = this.getConditionContext().getChildFalseSuccessor(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
override Instruction getChildFalseSuccessor(TranslatedCondition child) {
|
|
||||||
child = this.getOperand() and
|
|
||||||
result = this.getConditionContext().getChildTrueSuccessor(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
override TranslatedCondition getOperand() {
|
|
||||||
result = getTranslatedCondition(expr.getOperand().getFullyConverted())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class TranslatedNativeCondition extends TranslatedCondition, TTranslatedNativeCondition {
|
abstract class TranslatedNativeCondition extends TranslatedCondition, TTranslatedNativeCondition {
|
||||||
TranslatedNativeCondition() { this = TTranslatedNativeCondition(expr) }
|
TranslatedNativeCondition() { this = TTranslatedNativeCondition(expr) }
|
||||||
|
|
||||||
|
|||||||
@@ -190,10 +190,7 @@ private predicate isNativeCondition(Expr expr) {
|
|||||||
* depending on context.
|
* depending on context.
|
||||||
*/
|
*/
|
||||||
private predicate isFlexibleCondition(Expr expr) {
|
private predicate isFlexibleCondition(Expr expr) {
|
||||||
(
|
expr instanceof ParenthesisExpr and
|
||||||
expr instanceof ParenthesisExpr or
|
|
||||||
expr instanceof NotExpr
|
|
||||||
) and
|
|
||||||
usedAsCondition(expr) and
|
usedAsCondition(expr) and
|
||||||
not isIRConstant(expr)
|
not isIRConstant(expr)
|
||||||
}
|
}
|
||||||
@@ -218,11 +215,6 @@ private predicate usedAsCondition(Expr expr) {
|
|||||||
condExpr.getCondition().getFullyConverted() = expr and not condExpr.isTwoOperand()
|
condExpr.getCondition().getFullyConverted() = expr and not condExpr.isTwoOperand()
|
||||||
)
|
)
|
||||||
or
|
or
|
||||||
exists(NotExpr notExpr |
|
|
||||||
notExpr.getOperand().getFullyConverted() = expr and
|
|
||||||
usedAsCondition(notExpr)
|
|
||||||
)
|
|
||||||
or
|
|
||||||
exists(ParenthesisExpr paren |
|
exists(ParenthesisExpr paren |
|
||||||
paren.getExpr() = expr and
|
paren.getExpr() = expr and
|
||||||
usedAsCondition(paren)
|
usedAsCondition(paren)
|
||||||
|
|||||||
Reference in New Issue
Block a user