Skip to content

Commit a9f1c95

Browse files
committed
C#: Rename shift assignment expression classes.
1 parent 8aa2c23 commit a9f1c95

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ class AssignRemExpr extends AssignArithmeticOperation, @assign_rem_expr {
150150
* operation (`AssignAndExpr`), a bitwise-or assignment
151151
* operation (`AssignOrExpr`), a bitwise exclusive-or assignment
152152
* operation (`AssignXorExpr`), a left-shift assignment
153-
* operation (`AssignLShiftExpr`), or a right-shift assignment
154-
* operation (`AssignRShiftExpr`).
153+
* operation (`AssignLeftShiftExpr`), or a right-shift assignment
154+
* operation (`AssignRightShiftExpr`).
155155
*/
156156
class AssignBitwiseOperation extends AssignOperation, @assign_bitwise_expr { }
157157

@@ -185,21 +185,27 @@ class AssignXorExpr extends AssignBitwiseOperation, @assign_xor_expr {
185185
/**
186186
* A left-shift assignment operation, for example `x <<= y`.
187187
*/
188-
class AssignLShiftExpr extends AssignBitwiseOperation, @assign_lshift_expr {
188+
class AssignLeftShiftExpr extends AssignBitwiseOperation, @assign_lshift_expr {
189189
override string getOperator() { result = "<<=" }
190190

191-
override string getAPrimaryQlClass() { result = "AssignLShiftExpr" }
191+
override string getAPrimaryQlClass() { result = "AssignLeftShiftExpr" }
192192
}
193193

194+
/** DEPRECATED: Alias for AssignLeftShipExpr. */
195+
deprecated class AssignLShiftExpr = AssignLeftShiftExpr;
196+
194197
/**
195198
* A right-shift assignment operation, for example `x >>= y`.
196199
*/
197-
class AssignRShiftExpr extends AssignBitwiseOperation, @assign_rshift_expr {
200+
class AssignRightShiftExpr extends AssignBitwiseOperation, @assign_rshift_expr {
198201
override string getOperator() { result = ">>=" }
199202

200-
override string getAPrimaryQlClass() { result = "AssignRShiftExpr" }
203+
override string getAPrimaryQlClass() { result = "AssignRightShiftExpr" }
201204
}
202205

206+
/** DEPRECATED: Alias for AssignRightShiftExpr. */
207+
deprecated class AssignRShiftExpr = AssignRightShiftExpr;
208+
203209
/**
204210
* An event assignment. Either an event addition (`AddEventExpr`) or an event
205211
* removal (`RemoveEventExpr`).

csharp/ql/src/experimental/ir/implementation/raw/internal/TranslatedExpr.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,8 +1377,8 @@ class TranslatedAssignOperation extends TranslatedAssignment {
13771377

13781378
private Type getConvertedLeftOperandType() {
13791379
if
1380-
expr instanceof AssignLShiftExpr or
1381-
expr instanceof AssignRShiftExpr
1380+
expr instanceof AssignLeftShiftExpr or
1381+
expr instanceof AssignRightShiftExpr
13821382
then result = this.getLeftOperand().getResultType()
13831383
else
13841384
// The right operand has already been converted to the type of the op.
@@ -1416,9 +1416,9 @@ class TranslatedAssignOperation extends TranslatedAssignment {
14161416
or
14171417
expr instanceof AssignXorExpr and result instanceof Opcode::BitXor
14181418
or
1419-
expr instanceof AssignLShiftExpr and result instanceof Opcode::ShiftLeft
1419+
expr instanceof AssignLeftShiftExpr and result instanceof Opcode::ShiftLeft
14201420
or
1421-
expr instanceof AssignRShiftExpr and result instanceof Opcode::ShiftRight
1421+
expr instanceof AssignRightShiftExpr and result instanceof Opcode::ShiftRight
14221422
}
14231423

14241424
override predicate hasInstruction(Opcode opcode, InstructionTag tag, CSharpType resultType) {

csharp/ql/test/experimental/ir/ir/PrintAst.expected

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,11 @@ assignop.cs:
152152
# 12| 0: [LocalVariableAccess] access to local variable c
153153
# 12| 1: [LocalVariableAccess] access to local variable a
154154
# 13| 7: [ExprStmt] ...;
155-
# 13| 0: [AssignLShiftExpr] ... <<= ...
155+
# 13| 0: [AssignLeftShiftExpr] ... <<= ...
156156
# 13| 0: [LocalVariableAccess] access to local variable c
157157
# 13| 1: [IntLiteral] 2
158158
# 14| 8: [ExprStmt] ...;
159-
# 14| 0: [AssignRShiftExpr] ... >>= ...
159+
# 14| 0: [AssignRightShiftExpr] ... >>= ...
160160
# 14| 0: [LocalVariableAccess] access to local variable c
161161
# 14| 1: [IntLiteral] 2
162162
# 15| 9: [ExprStmt] ...;

0 commit comments

Comments
 (0)