Skip to content

Commit b36be00

Browse files
authored
Merge pull request github#11834 from michaelnebel/csharp/operators
C# 11: Extractor and library support for Unsigned right shift.
2 parents 3b15f23 + c1c0ff4 commit b36be00

File tree

57 files changed

+10976
-2372
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+10976
-2372
lines changed

cpp/ql/lib/semmle/code/cpp/ir/implementation/Opcode.qll

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ private newtype TOpcode =
3030
TNegate() or
3131
TShiftLeft() or
3232
TShiftRight() or
33+
TUnsignedShiftRight() or
3334
TBitAnd() or
3435
TBitOr() or
3536
TBitXor() or
@@ -652,6 +653,15 @@ module Opcode {
652653
final override string toString() { result = "ShiftRight" }
653654
}
654655

656+
/**
657+
* The `Opcode` for a `UnsignedShiftRightInstruction`.
658+
*
659+
* See the `UnsignedShiftRightInstruction` documentation for more details.
660+
*/
661+
class UnsignedShiftRight extends BinaryBitwiseOpcode, TUnsignedShiftRight {
662+
final override string toString() { result = "UnsignedShiftRight" }
663+
}
664+
655665
/**
656666
* The `Opcode` for a `BitAndInstruction`.
657667
*

cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/Instruction.qll

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,6 +1204,17 @@ class ShiftRightInstruction extends BinaryBitwiseInstruction {
12041204
ShiftRightInstruction() { this.getOpcode() instanceof Opcode::ShiftRight }
12051205
}
12061206

1207+
/**
1208+
* An instruction that shifts its left operand to the right by the number of bits specified by its
1209+
* right operand.
1210+
*
1211+
* Both operands must have an integer type. The result has the same type as the left operand.
1212+
* The leftmost bits are zero-filled.
1213+
*/
1214+
class UnsignedShiftRightInstruction extends BinaryBitwiseInstruction {
1215+
UnsignedShiftRightInstruction() { this.getOpcode() instanceof Opcode::UnsignedShiftRight }
1216+
}
1217+
12071218
/**
12081219
* An instruction that performs a binary arithmetic operation involving at least one pointer
12091220
* operand.

cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/Instruction.qll

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,6 +1204,17 @@ class ShiftRightInstruction extends BinaryBitwiseInstruction {
12041204
ShiftRightInstruction() { this.getOpcode() instanceof Opcode::ShiftRight }
12051205
}
12061206

1207+
/**
1208+
* An instruction that shifts its left operand to the right by the number of bits specified by its
1209+
* right operand.
1210+
*
1211+
* Both operands must have an integer type. The result has the same type as the left operand.
1212+
* The leftmost bits are zero-filled.
1213+
*/
1214+
class UnsignedShiftRightInstruction extends BinaryBitwiseInstruction {
1215+
UnsignedShiftRightInstruction() { this.getOpcode() instanceof Opcode::UnsignedShiftRight }
1216+
}
1217+
12071218
/**
12081219
* An instruction that performs a binary arithmetic operation involving at least one pointer
12091220
* operand.

cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/Instruction.qll

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,6 +1204,17 @@ class ShiftRightInstruction extends BinaryBitwiseInstruction {
12041204
ShiftRightInstruction() { this.getOpcode() instanceof Opcode::ShiftRight }
12051205
}
12061206

1207+
/**
1208+
* An instruction that shifts its left operand to the right by the number of bits specified by its
1209+
* right operand.
1210+
*
1211+
* Both operands must have an integer type. The result has the same type as the left operand.
1212+
* The leftmost bits are zero-filled.
1213+
*/
1214+
class UnsignedShiftRightInstruction extends BinaryBitwiseInstruction {
1215+
UnsignedShiftRightInstruction() { this.getOpcode() instanceof Opcode::UnsignedShiftRight }
1216+
}
1217+
12071218
/**
12081219
* An instruction that performs a binary arithmetic operation involving at least one pointer
12091220
* operand.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Expression extends @expr {
2+
string toString() { none() }
3+
}
4+
5+
class TypeOrRef extends @type_or_ref {
6+
string toString() { none() }
7+
}
8+
9+
from Expression e, int k, int kind, TypeOrRef t
10+
where
11+
expressions(e, k, t) and
12+
if k = [133, 134] then kind = 106 else kind = k
13+
select e, kind, t

0 commit comments

Comments
 (0)