mirror of
https://github.com/github/codeql.git
synced 2026-02-28 21:03:50 +01:00
Fix additional PR review findings
This commit is contained in:
@@ -328,21 +328,20 @@ Sign exprSign(Expr e) {
|
||||
|
||||
/** Gets a possible sign for `e` from the signs of its child nodes. */
|
||||
private Sign specificSubExprSign(Expr e) {
|
||||
result = exprSign(getASubExpr(e))
|
||||
result = exprSign(getASubExprWithSameSign(e))
|
||||
or
|
||||
e =
|
||||
any(DivExpr div |
|
||||
result = exprSign(div.getLeftOperand()) and
|
||||
result != TZero() and
|
||||
div.getRightOperand().(RealLiteral).getValue().toFloat() = 0
|
||||
)
|
||||
exists(DivExpr div | div = e |
|
||||
result = exprSign(div.getLeftOperand()) and
|
||||
result != TZero() and
|
||||
div.getRightOperand().(RealLiteral).getValue().toFloat() = 0
|
||||
)
|
||||
or
|
||||
exists(UnaryExpr unary | unary = e |
|
||||
exists(UnaryOperation unary | unary = e |
|
||||
result = exprSign(unary.getOperand()).applyUnaryOp(unary.getOp())
|
||||
)
|
||||
or
|
||||
exists(Sign s1, Sign s2 | binaryOpSigns(e, s1, s2) |
|
||||
result = s1.applyBinaryOp(s2, e.(BinaryExpr).getOp())
|
||||
result = s1.applyBinaryOp(s2, e.(BinaryOperation).getOp())
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -45,21 +45,6 @@ module Private {
|
||||
|
||||
class DivExpr = J::DivExpr;
|
||||
|
||||
class BinaryOperation extends J::Expr {
|
||||
BinaryOperation() {
|
||||
this instanceof J::BinaryExpr or
|
||||
this instanceof J::AssignOp
|
||||
}
|
||||
|
||||
Expr getLeftOperand() {
|
||||
result = this.(J::BinaryExpr).getLeftOperand() or result = this.(J::AssignOp).getDest()
|
||||
}
|
||||
|
||||
Expr getRightOperand() {
|
||||
result = this.(J::BinaryExpr).getRightOperand() or result = this.(J::AssignOp).getRhs()
|
||||
}
|
||||
}
|
||||
|
||||
/** Class to represent float and double literals. */
|
||||
class RealLiteral extends J::Literal {
|
||||
RealLiteral() {
|
||||
@@ -68,9 +53,9 @@ module Private {
|
||||
}
|
||||
}
|
||||
|
||||
/** Class to represent unary expressions. */
|
||||
class UnaryExpr extends J::Expr {
|
||||
UnaryExpr() {
|
||||
/** Class to represent unary operation. */
|
||||
class UnaryOperation extends J::Expr {
|
||||
UnaryOperation() {
|
||||
this instanceof J::PreIncExpr or
|
||||
this instanceof J::PreDecExpr or
|
||||
this instanceof J::MinusExpr or
|
||||
@@ -97,9 +82,9 @@ module Private {
|
||||
}
|
||||
}
|
||||
|
||||
/** Class to represent binary expressions. */
|
||||
class BinaryExpr extends J::Expr {
|
||||
BinaryExpr() {
|
||||
/** Class to represent binary operation. */
|
||||
class BinaryOperation extends J::Expr {
|
||||
BinaryOperation() {
|
||||
this instanceof J::AddExpr or
|
||||
this instanceof J::AssignAddExpr or
|
||||
this instanceof J::SubExpr or
|
||||
@@ -170,6 +155,14 @@ module Private {
|
||||
or
|
||||
this instanceof J::AssignURShiftExpr and result = TURShiftOp()
|
||||
}
|
||||
|
||||
Expr getLeftOperand() {
|
||||
result = this.(J::BinaryExpr).getLeftOperand() or result = this.(J::AssignOp).getDest()
|
||||
}
|
||||
|
||||
Expr getRightOperand() {
|
||||
result = this.(J::BinaryExpr).getRightOperand() or result = this.(J::AssignOp).getRhs()
|
||||
}
|
||||
}
|
||||
|
||||
predicate ssaRead = RU::ssaRead/2;
|
||||
@@ -300,7 +293,7 @@ private module Impl {
|
||||
}
|
||||
|
||||
/** Returns a sub expression of `e` for expression types where the sign depends on the child. */
|
||||
Expr getASubExpr(Expr e) {
|
||||
Expr getASubExprWithSameSign(Expr e) {
|
||||
result = e.(AssignExpr).getSource() or
|
||||
result = e.(PlusExpr).getExpr() or
|
||||
result = e.(PostIncExpr).getExpr() or
|
||||
|
||||
Reference in New Issue
Block a user