mirror of
https://github.com/github/codeql.git
synced 2026-03-30 20:28:15 +02:00
C#: Make Assignment extend BinaryOperation.
This commit is contained in:
@@ -11,7 +11,7 @@ import Expr
|
||||
* (`LocalVariableDeclAndInitExpr`), a simple assignment (`AssignExpr`), or
|
||||
* an assignment operation (`AssignOperation`).
|
||||
*/
|
||||
class Assignment extends Operation, @assign_expr {
|
||||
class Assignment extends BinaryOperation, @assign_expr {
|
||||
Assignment() {
|
||||
this instanceof LocalVariableDeclExpr
|
||||
implies
|
||||
@@ -20,6 +20,10 @@ class Assignment extends Operation, @assign_expr {
|
||||
expr_parent(_, 0, this)
|
||||
}
|
||||
|
||||
override Expr getLeftOperand() { result = this.getChild(1) }
|
||||
|
||||
override Expr getRightOperand() { result = this.getChild(0) }
|
||||
|
||||
/** Gets the left operand of this assignment. */
|
||||
Expr getLValue() { result = this.getChild(1) }
|
||||
|
||||
|
||||
@@ -233,7 +233,8 @@ class UnaryOperation extends Operation, @un_op {
|
||||
* A binary operation. Either a binary arithmetic operation
|
||||
* (`BinaryArithmeticOperation`), a binary bitwise operation
|
||||
* (`BinaryBitwiseOperation`), a comparison operation (`ComparisonOperation`),
|
||||
* or a binary logical operation (`BinaryLogicalOperation`).
|
||||
* a binary logical operation (`BinaryLogicalOperation`), or an
|
||||
* assignment (`Assignment`).
|
||||
*/
|
||||
class BinaryOperation extends Operation, @bin_op {
|
||||
/** Gets the left operand of this binary operation. */
|
||||
|
||||
@@ -5,4 +5,5 @@
|
||||
import csharp
|
||||
|
||||
from BinaryOperation e
|
||||
where not e instanceof Assignment
|
||||
select e, e.getAnOperand()
|
||||
|
||||
Reference in New Issue
Block a user