Skip to content

Commit 36980bb

Browse files
committed
C#: Rename shift expression classes.
1 parent a9f1c95 commit 36980bb

File tree

7 files changed

+37
-22
lines changed

7 files changed

+37
-22
lines changed

csharp/ql/lib/semmle/code/csharp/dataflow/ModulusAnalysis.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ private predicate evenlyDivisibleExpr(Expr e, int factor) {
105105
exists(ConstantIntegerExpr c, int k | k = c.getIntValue() |
106106
e.(MulExpr).getAnOperand() = c and factor = k.abs() and factor >= 2
107107
or
108-
e.(LShiftExpr).getRhs() = c and factor = 2.pow(k) and k > 0
108+
e.(LeftShiftExpr).getRhs() = c and factor = 2.pow(k) and k > 0
109109
or
110110
e.(BitwiseAndExpr).getAnOperand() = c and factor = max(int f | andmaskFactor(k, f))
111111
)

csharp/ql/lib/semmle/code/csharp/dataflow/internal/rangeanalysis/ModulusAnalysisSpecific.qll

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ module Private {
3030

3131
class MulExpr = RU::ExprNode::MulExpr;
3232

33-
class LShiftExpr = RU::ExprNode::LShiftExpr;
33+
class LeftShiftExpr = RU::ExprNode::LeftShiftExpr;
34+
35+
/** DEPRECATED: Alias for LeftShiftExpr. */
36+
deprecated class LShiftExpr = LeftShiftExpr;
3437

3538
predicate guardDirectlyControlsSsaRead = RU::guardControlsSsaRead/3;
3639

csharp/ql/lib/semmle/code/csharp/dataflow/internal/rangeanalysis/RangeUtils.qll

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -391,19 +391,25 @@ module ExprNode {
391391
}
392392

393393
/** A left-shift operation. */
394-
class LShiftExpr extends BinaryOperation {
395-
override CS::LShiftExpr e;
394+
class LeftShiftExpr extends BinaryOperation {
395+
override CS::LeftShiftExpr e;
396396

397397
override TLShiftOp getOp() { any() }
398398
}
399399

400+
/** DEPRECATED: Alias for LeftShiftExpr. */
401+
deprecated class LShiftExpr = LeftShiftExpr;
402+
400403
/** A right-shift operation. */
401-
class RShiftExpr extends BinaryOperation {
402-
override CS::RShiftExpr e;
404+
class RightShiftExpr extends BinaryOperation {
405+
override CS::RightShiftExpr e;
403406

404407
override TRShiftOp getOp() { any() }
405408
}
406409

410+
/** DEPRECATED: Alias for RightShiftExpr. */
411+
deprecated class RShiftExpr = RightShiftExpr;
412+
407413
/** A conditional expression. */
408414
class ConditionalExpr extends ExprNode {
409415
override CS::ConditionalExpr e;

csharp/ql/lib/semmle/code/csharp/dataflow/internal/rangeanalysis/SignAnalysisSpecific.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ private module Impl {
211211
not e.getExpr() instanceof BitwiseAndExpr and
212212
not e.getExpr() instanceof BitwiseOrExpr and
213213
not e.getExpr() instanceof BitwiseXorExpr and
214-
not e.getExpr() instanceof LShiftExpr and
215-
not e.getExpr() instanceof RShiftExpr and
214+
not e.getExpr() instanceof LeftShiftExpr and
215+
not e.getExpr() instanceof RightShiftExpr and
216216
not e.getExpr() instanceof ConditionalExpr and
217217
not e.getExpr() instanceof RefExpr and
218218
not e.getExpr() instanceof LocalVariableDeclAndInitExpr and

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ 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 (`LShiftExpr`), or a right-shift operation (`RShiftExpr`).
34+
* operation (`LeftShiftExpr`), or a right-shift operation (`RightShiftExpr`).
3535
*/
3636
class BinaryBitwiseOperation extends BitwiseOperation, BinaryOperation, @bin_bit_op_expr {
3737
override string getOperator() { none() }
@@ -40,21 +40,27 @@ class BinaryBitwiseOperation extends BitwiseOperation, BinaryOperation, @bin_bit
4040
/**
4141
* A left-shift operation, for example `x << y`.
4242
*/
43-
class LShiftExpr extends BinaryBitwiseOperation, @lshift_expr {
43+
class LeftShiftExpr extends BinaryBitwiseOperation, @lshift_expr {
4444
override string getOperator() { result = "<<" }
4545

46-
override string getAPrimaryQlClass() { result = "LShiftExpr" }
46+
override string getAPrimaryQlClass() { result = "LeftShiftExpr" }
4747
}
4848

49+
/** DEPRECATED: Alias for LeftShiftExpr. */
50+
deprecated class LShiftExpr = LeftShiftExpr;
51+
4952
/**
5053
* A right-shift operation, for example `x >> y`.
5154
*/
52-
class RShiftExpr extends BinaryBitwiseOperation, @rshift_expr {
55+
class RightShiftExpr extends BinaryBitwiseOperation, @rshift_expr {
5356
override string getOperator() { result = ">>" }
5457

55-
override string getAPrimaryQlClass() { result = "RShiftExpr" }
58+
override string getAPrimaryQlClass() { result = "RightShiftExpr" }
5659
}
5760

61+
/** DEPRECATED: Alias for RightShiftExpr. */
62+
deprecated class RShiftExpr = RightShiftExpr;
63+
5864
/**
5965
* A bitwise-and operation, for example `x & y`.
6066
*/

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,9 +1091,9 @@ class TranslatedCast extends TranslatedNonConstantExpr {
10911091
}
10921092

10931093
private Opcode binaryBitwiseOpcode(BinaryBitwiseOperation expr) {
1094-
expr instanceof LShiftExpr and result instanceof Opcode::ShiftLeft
1094+
expr instanceof LeftShiftExpr and result instanceof Opcode::ShiftLeft
10951095
or
1096-
expr instanceof RShiftExpr and result instanceof Opcode::ShiftRight
1096+
expr instanceof RightShiftExpr and result instanceof Opcode::ShiftRight
10971097
or
10981098
expr instanceof BitwiseAndExpr and result instanceof Opcode::BitAnd
10991099
or

csharp/ql/test/library-tests/indexers/PrintAst.expected

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ indexers.cs:
2525
# 18| -1: [TypeMention] Int32[]
2626
# 18| 1: [TypeMention] int
2727
# 18| 0: [AddExpr] ... + ...
28-
# 18| 0: [RShiftExpr] ... >> ...
28+
# 18| 0: [RightShiftExpr] ... >> ...
2929
# 18| 0: [SubExpr] ... - ...
3030
# 18| 0: [ParameterAccess] access to parameter length
3131
# 18| 1: [IntLiteral] 1
@@ -68,10 +68,10 @@ indexers.cs:
6868
# 32| 0: [BitwiseAndExpr] ... & ...
6969
# 32| 0: [ArrayAccess] access to array element
7070
# 32| -1: [FieldAccess] access to field bits
71-
# 32| 0: [RShiftExpr] ... >> ...
71+
# 32| 0: [RightShiftExpr] ... >> ...
7272
# 32| 0: [ParameterAccess] access to parameter index
7373
# 32| 1: [IntLiteral] 5
74-
# 32| 1: [LShiftExpr] ... << ...
74+
# 32| 1: [LeftShiftExpr] ... << ...
7575
# 32| 0: [IntLiteral] 1
7676
# 32| 1: [ParameterAccess] access to parameter index
7777
# 32| 1: [IntLiteral] 0
@@ -99,22 +99,22 @@ indexers.cs:
9999
# 42| 0: [AssignOrExpr] ... |= ...
100100
# 42| 0: [ArrayAccess] access to array element
101101
# 42| -1: [FieldAccess] access to field bits
102-
# 42| 0: [RShiftExpr] ... >> ...
102+
# 42| 0: [RightShiftExpr] ... >> ...
103103
# 42| 0: [ParameterAccess] access to parameter index
104104
# 42| 1: [IntLiteral] 5
105-
# 42| 1: [LShiftExpr] ... << ...
105+
# 42| 1: [LeftShiftExpr] ... << ...
106106
# 42| 0: [IntLiteral] 1
107107
# 42| 1: [ParameterAccess] access to parameter index
108108
# 45| 2: [BlockStmt] {...}
109109
# 46| 0: [ExprStmt] ...;
110110
# 46| 0: [AssignAndExpr] ... &= ...
111111
# 46| 0: [ArrayAccess] access to array element
112112
# 46| -1: [FieldAccess] access to field bits
113-
# 46| 0: [RShiftExpr] ... >> ...
113+
# 46| 0: [RightShiftExpr] ... >> ...
114114
# 46| 0: [ParameterAccess] access to parameter index
115115
# 46| 1: [IntLiteral] 5
116116
# 46| 1: [ComplementExpr] ~...
117-
# 46| 0: [LShiftExpr] ... << ...
117+
# 46| 0: [LeftShiftExpr] ... << ...
118118
# 46| 0: [IntLiteral] 1
119119
# 46| 1: [ParameterAccess] access to parameter index
120120
# 53| 2: [Class] CountPrimes

0 commit comments

Comments
 (0)