Skip to content

Commit 2038a07

Browse files
committed
C#: Move arithmetic like classes from Operation.qll to ArithmeticOperation.qll.
1 parent d2aa8c1 commit 2038a07

2 files changed

Lines changed: 39 additions & 39 deletions

File tree

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ class ArithmeticOperation extends Operation, @arith_operation {
1515
override string getOperator() { none() }
1616
}
1717

18+
/**
19+
* A binary arithmetic operation. Either a binary arithmetic expression (`BinaryArithmeticExpr`) or
20+
* an arithmetic assignment operation (`AssignArithmeticExpr`).
21+
*/
22+
class BinaryArithmeticOperation extends ArithmeticOperation, BinaryOperation, @bin_arith_operation {
23+
override string getOperator() { none() }
24+
}
25+
1826
/**
1927
* A unary arithmetic operation. Either a unary minus operation
2028
* (`UnaryMinusExpr`), a unary plus operation (`UnaryPlusExpr`),
@@ -94,6 +102,37 @@ class PostDecrExpr extends DecrementOperation, @post_decr_expr {
94102
override string getAPrimaryQlClass() { result = "PostDecrExpr" }
95103
}
96104

105+
/**
106+
* An addition operation, either `x + y` or `x += y`.
107+
*/
108+
class AddOperation extends BinaryArithmeticOperation, @add_operation { }
109+
110+
/**
111+
* A subtraction operation, either `x - y` or `x -= y`.
112+
*/
113+
class SubOperation extends BinaryArithmeticOperation, @sub_operation { }
114+
115+
/**
116+
* A multiplication operation, either `x * y` or `x *= y`.
117+
*/
118+
class MulOperation extends BinaryArithmeticOperation, @mul_operation { }
119+
120+
/**
121+
* A division operation, either `x / y` or `x /= y`.
122+
*/
123+
class DivOperation extends BinaryArithmeticOperation, @div_operation {
124+
/** Gets the numerator of this division operation. */
125+
Expr getNumerator() { result = this.getLeftOperand() }
126+
127+
/** Gets the denominator of this division operation. */
128+
Expr getDenominator() { result = this.getRightOperand() }
129+
}
130+
131+
/**
132+
* A remainder operation, either `x % y` or `x %= y`.
133+
*/
134+
class RemOperation extends BinaryArithmeticOperation, @rem_operation { }
135+
97136
/**
98137
* A binary arithmetic expression. Either an addition expression
99138
* (`AddExpr`), a subtraction expression (`SubExpr`), a multiplication

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

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,6 @@
44

55
import Expr
66

7-
/**
8-
* A binary arithmetic operation. Either a binary arithmetic expression (`BinaryArithmeticExpr`) or
9-
* an arithmetic assignment operation (`AssignArithmeticExpr`).
10-
*/
11-
class BinaryArithmeticOperation extends ArithmeticOperation, BinaryOperation, @bin_arith_operation {
12-
override string getOperator() { none() }
13-
}
14-
15-
/**
16-
* An addition operation, either `x + y` or `x += y`.
17-
*/
18-
class AddOperation extends BinaryArithmeticOperation, @add_operation { }
19-
20-
/**
21-
* A subtraction operation, either `x - y` or `x -= y`.
22-
*/
23-
class SubOperation extends BinaryArithmeticOperation, @sub_operation { }
24-
25-
/**
26-
* A multiplication operation, either `x * y` or `x *= y`.
27-
*/
28-
class MulOperation extends BinaryArithmeticOperation, @mul_operation { }
29-
30-
/**
31-
* A division operation, either `x / y` or `x /= y`.
32-
*/
33-
class DivOperation extends BinaryArithmeticOperation, @div_operation {
34-
/** Gets the numerator of this division operation. */
35-
Expr getNumerator() { result = this.getLeftOperand() }
36-
37-
/** Gets the denominator of this division operation. */
38-
Expr getDenominator() { result = this.getRightOperand() }
39-
}
40-
41-
/**
42-
* A remainder operation, either `x % y` or `x %= y`.
43-
*/
44-
class RemOperation extends BinaryArithmeticOperation, @rem_operation { }
45-
467
/**
478
* A bitwise-and operation, either `x & y` or `x &= y`.
489
*/

0 commit comments

Comments
 (0)