mirror of
https://github.com/github/codeql.git
synced 2026-03-30 20:28:15 +02:00
Merge pull request #21417 from aschackmull/csharp/binary-assignment
C#: Make Assignment extend BinaryOperation.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,2 @@
|
||||
description: Remove inclusion of @assign_expr in @bin_op
|
||||
compatibility: full
|
||||
@@ -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) }
|
||||
|
||||
|
||||
@@ -244,7 +244,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. */
|
||||
|
||||
@@ -1261,10 +1261,10 @@ case @expr.kind of
|
||||
@rel_op_expr = @gt_expr | @lt_expr| @ge_expr | @le_expr;
|
||||
@comp_expr = @equality_op_expr | @rel_op_expr;
|
||||
|
||||
@op_expr = @assign_expr | @un_op | @bin_op | @ternary_op;
|
||||
@op_expr = @un_op | @bin_op | @ternary_op;
|
||||
|
||||
@ternary_op = @ternary_log_op_expr;
|
||||
@bin_op = @bin_arith_op_expr | @bin_log_op_expr | @bin_bit_op_expr | @comp_expr;
|
||||
@bin_op = @assign_expr | @bin_arith_op_expr | @bin_log_op_expr | @bin_bit_op_expr | @comp_expr;
|
||||
@un_op = @un_arith_op_expr | @un_log_op_expr | @un_bit_op_expr | @sizeof_expr
|
||||
| @pointer_indirection_expr | @address_of_expr;
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,2 @@
|
||||
description: Expand @bin_op union to include @assign_expr
|
||||
compatibility: full
|
||||
@@ -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