Skip to content

Commit 9eb7933

Browse files
committed
C#: Implement library support for unsigned right shift.
1 parent 99b7bc3 commit 9eb7933

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

csharp/ql/lib/semmle/code/csharp/exprs/Assignment.qll

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ class AssignRemExpr extends AssignArithmeticOperation, @assign_rem_expr {
151151
* operation (`AssignOrExpr`), a bitwise exclusive-or assignment
152152
* operation (`AssignXorExpr`), a left-shift assignment
153153
* operation (`AssignLeftShiftExpr`), or a right-shift assignment
154-
* operation (`AssignRightShiftExpr`).
154+
* operation (`AssignRightShiftExpr`), or an unsigned right-shift assignment
155+
* operation (`AssignUnsignedRightShiftExpr`).
155156
*/
156157
class AssignBitwiseOperation extends AssignOperation, @assign_bitwise_expr { }
157158

@@ -206,6 +207,15 @@ class AssignRightShiftExpr extends AssignBitwiseOperation, @assign_rshift_expr {
206207
/** DEPRECATED: Alias for AssignRightShiftExpr. */
207208
deprecated class AssignRShiftExpr = AssignRightShiftExpr;
208209

210+
/**
211+
* An unsigned right-shift assignment operation, for example `x >>>= y`.
212+
*/
213+
class AssignUnsighedRightShiftExpr extends AssignBitwiseOperation, @assign_urshift_expr {
214+
override string getOperator() { result = ">>>=" }
215+
216+
override string getAPrimaryQlClass() { result = "AssignUnsighedRightShiftExpr" }
217+
}
218+
209219
/**
210220
* An event assignment. Either an event addition (`AddEventExpr`) or an event
211221
* removal (`RemoveEventExpr`).

csharp/ql/lib/semmle/code/csharp/exprs/BitwiseOperation.qll

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ class ComplementExpr extends UnaryBitwiseOperation, @bit_not_expr {
3131
* A binary bitwise operation. Either a bitwise-and operation
3232
* (`BitwiseAndExpr`), a bitwise-or operation (`BitwiseOrExpr`),
3333
* a bitwise exclusive-or operation (`BitwiseXorExpr`), a left-shift
34-
* operation (`LeftShiftExpr`), or a right-shift operation (`RightShiftExpr`).
34+
* operation (`LeftShiftExpr`), a right-shift operation (`RightShiftExpr`),
35+
* or an unsigned right-shift operation (`UnsignedRightShiftExpr`).
3536
*/
3637
class BinaryBitwiseOperation extends BitwiseOperation, BinaryOperation, @bin_bit_op_expr {
3738
override string getOperator() { none() }
@@ -61,6 +62,15 @@ class RightShiftExpr extends BinaryBitwiseOperation, @rshift_expr {
6162
/** DEPRECATED: Alias for RightShiftExpr. */
6263
deprecated class RShiftExpr = RightShiftExpr;
6364

65+
/**
66+
* An unsigned right-shift operation, for example `x >>> y`.
67+
*/
68+
class UnsignedRightShiftExpr extends BinaryBitwiseOperation, @urshift_expr {
69+
override string getOperator() { result = ">>>" }
70+
71+
override string getAPrimaryQlClass() { result = "UnsignedRightShiftExpr" }
72+
}
73+
6474
/**
6575
* A bitwise-and operation, for example `x & y`.
6676
*/

0 commit comments

Comments
 (0)