зеркало из https://github.com/github/codeql.git
Address review by Anders.
This commit is contained in:
Родитель
5d4b6c3a8c
Коммит
0e7a08201f
|
@ -25,30 +25,19 @@ Expr enumConstEquality(Expr e, boolean polarity, EnumConstant c) {
|
|||
}
|
||||
|
||||
/** Gets an instanceof expression of `v` with type `type` */
|
||||
InstanceOfExpr instanceofExpr(SsaVariable v, Expr type) {
|
||||
result.getTypeName() = type and
|
||||
InstanceOfExpr instanceofExpr(SsaVariable v, Type type) {
|
||||
result.getTypeName().getType() = type and
|
||||
result.getExpr() = v.getAUse()
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an expression of the form `v1` == `v2` or `v1` != `v2`.
|
||||
* Gets an expression of the form `v1 == v2` or `v1 != v2`.
|
||||
* The predicate is symmetric in `v1` and `v2`.
|
||||
*/
|
||||
BinaryExpr varComparisonExpr(SsaVariable v1, SsaVariable v2, boolean isEqualExpr) {
|
||||
(
|
||||
result.getLeftOperand() = v1.getAUse() and
|
||||
result.getRightOperand() = v2.getAUse()
|
||||
or
|
||||
result.getLeftOperand() = v2.getAUse() and
|
||||
result.getRightOperand() = v1.getAUse()
|
||||
) and
|
||||
(
|
||||
result instanceof EQExpr and
|
||||
isEqualExpr = true
|
||||
or
|
||||
result instanceof NEExpr and
|
||||
isEqualExpr = false
|
||||
)
|
||||
EqualityTest varEqualityTestExpr(SsaVariable v1, SsaVariable v2, boolean isEqualExpr) {
|
||||
result.hasOperands(v1.getAUse(), v2.getAUse()) and
|
||||
result instanceof EqualityTest and
|
||||
isEqualExpr = result.polarity()
|
||||
}
|
||||
|
||||
/** Gets an expression that is provably not `null`. */
|
||||
|
|
|
@ -516,16 +516,15 @@ private predicate correlatedConditions(
|
|||
inverted = pol1.booleanXor(pol2)
|
||||
)
|
||||
or
|
||||
exists(SsaVariable v, Expr t1, Expr t2 |
|
||||
cond1.getCondition() = instanceofExpr(v, t1) and
|
||||
cond2.getCondition() = instanceofExpr(v, t2) and
|
||||
t1.getType() = t2.getType() and
|
||||
exists(SsaVariable v, Type type |
|
||||
cond1.getCondition() = instanceofExpr(v, type) and
|
||||
cond2.getCondition() = instanceofExpr(v, type) and
|
||||
inverted = false
|
||||
)
|
||||
or
|
||||
exists(SsaVariable v1, SsaVariable v2, boolean branch1, boolean branch2 |
|
||||
cond1.getCondition() = varComparisonExpr(v1, v2, branch1) and
|
||||
cond2.getCondition() = varComparisonExpr(v1, v2, branch2) and
|
||||
cond1.getCondition() = varEqualityTestExpr(v1, v2, branch1) and
|
||||
cond2.getCondition() = varEqualityTestExpr(v1, v2, branch2) and
|
||||
inverted = branch1.booleanXor(branch2)
|
||||
)
|
||||
)
|
||||
|
|
Загрузка…
Ссылка в новой задаче