mirror of
https://github.com/github/codeql.git
synced 2026-04-24 00:05:14 +02:00
Merge pull request #14254 from atorralba/atorralba/arithexpr-improv
Java: Consider AssignOps in ArithExpr
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
---
|
||||
category: minorAnalysis
|
||||
---
|
||||
* Improved the class `ArithExpr` of the `Overflow.qll` module to also include compound operators. Because of this, new alerts may be raised in queries related to overflows/underflows.
|
||||
@@ -80,11 +80,19 @@ class ArithExpr extends Expr {
|
||||
(
|
||||
this instanceof UnaryAssignExpr or
|
||||
this instanceof AddExpr or
|
||||
this instanceof AssignAddExpr or
|
||||
this instanceof MulExpr or
|
||||
this instanceof AssignMulExpr or
|
||||
this instanceof SubExpr or
|
||||
this instanceof DivExpr
|
||||
this instanceof AssignSubExpr or
|
||||
this instanceof DivExpr or
|
||||
this instanceof AssignDivExpr
|
||||
) and
|
||||
forall(Expr e | e = this.(BinaryExpr).getAnOperand() or e = this.(UnaryAssignExpr).getExpr() |
|
||||
forall(Expr e |
|
||||
e = this.(BinaryExpr).getAnOperand() or
|
||||
e = this.(UnaryAssignExpr).getExpr() or
|
||||
e = this.(AssignOp).getSource()
|
||||
|
|
||||
e.getType() instanceof NumType
|
||||
)
|
||||
}
|
||||
@@ -103,17 +111,21 @@ class ArithExpr extends Expr {
|
||||
*/
|
||||
Expr getLeftOperand() {
|
||||
result = this.(BinaryExpr).getLeftOperand() or
|
||||
result = this.(UnaryAssignExpr).getExpr()
|
||||
result = this.(UnaryAssignExpr).getExpr() or
|
||||
result = this.(AssignOp).getDest()
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the right-hand operand if this is a binary expression.
|
||||
*/
|
||||
Expr getRightOperand() { result = this.(BinaryExpr).getRightOperand() }
|
||||
Expr getRightOperand() {
|
||||
result = this.(BinaryExpr).getRightOperand() or result = this.(AssignOp).getRhs()
|
||||
}
|
||||
|
||||
/** Gets an operand of this arithmetic expression. */
|
||||
Expr getAnOperand() {
|
||||
result = this.(BinaryExpr).getAnOperand() or
|
||||
result = this.(UnaryAssignExpr).getExpr()
|
||||
result = this.(UnaryAssignExpr).getExpr() or
|
||||
result = this.(AssignOp).getSource()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user