File tree Expand file tree Collapse file tree 3 files changed +8
-2
lines changed
lib/semmle/code/csharp/exprs Expand file tree Collapse file tree 3 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ import Expr
1111 * (`LocalVariableDeclAndInitExpr`), a simple assignment (`AssignExpr`), or
1212 * an assignment operation (`AssignOperation`).
1313 */
14- class Assignment extends Operation , @assign_expr {
14+ class Assignment extends BinaryOperation , @assign_expr {
1515 Assignment ( ) {
1616 this instanceof LocalVariableDeclExpr
1717 implies
@@ -20,6 +20,10 @@ class Assignment extends Operation, @assign_expr {
2020 expr_parent ( _, 0 , this )
2121 }
2222
23+ override Expr getLeftOperand ( ) { result = this .getChild ( 1 ) }
24+
25+ override Expr getRightOperand ( ) { result = this .getChild ( 0 ) }
26+
2327 /** Gets the left operand of this assignment. */
2428 Expr getLValue ( ) { result = this .getChild ( 1 ) }
2529
Original file line number Diff line number Diff line change @@ -233,7 +233,8 @@ class UnaryOperation extends Operation, @un_op {
233233 * A binary operation. Either a binary arithmetic operation
234234 * (`BinaryArithmeticOperation`), a binary bitwise operation
235235 * (`BinaryBitwiseOperation`), a comparison operation (`ComparisonOperation`),
236- * or a binary logical operation (`BinaryLogicalOperation`).
236+ * a binary logical operation (`BinaryLogicalOperation`), or an
237+ * assignment (`Assignment`).
237238 */
238239class BinaryOperation extends Operation , @bin_op {
239240 /** Gets the left operand of this binary operation. */
Original file line number Diff line number Diff line change 55import csharp
66
77from BinaryOperation e
8+ where not e instanceof Assignment
89select e , e .getAnOperand ( )
You can’t perform that action at this time.
0 commit comments