diff --git a/csharp/ql/lib/semmle/code/csharp/exprs/ArithmeticOperation.qll b/csharp/ql/lib/semmle/code/csharp/exprs/ArithmeticOperation.qll index efa038cc3a1..45e9dc61cd0 100644 --- a/csharp/ql/lib/semmle/code/csharp/exprs/ArithmeticOperation.qll +++ b/csharp/ql/lib/semmle/code/csharp/exprs/ArithmeticOperation.qll @@ -15,6 +15,14 @@ class ArithmeticOperation extends Operation, @arith_operation { override string getOperator() { none() } } +/** + * A binary arithmetic operation. Either a binary arithmetic expression (`BinaryArithmeticExpr`) or + * an arithmetic assignment expression (`AssignArithmeticExpr`). + */ +class BinaryArithmeticOperation extends ArithmeticOperation, BinaryOperation, @bin_arith_operation { + override string getOperator() { none() } +} + /** * A unary arithmetic operation. Either a unary minus operation * (`UnaryMinusExpr`), a unary plus operation (`UnaryPlusExpr`), @@ -94,6 +102,37 @@ class PostDecrExpr extends DecrementOperation, @post_decr_expr { override string getAPrimaryQlClass() { result = "PostDecrExpr" } } +/** + * An addition operation, either `x + y` or `x += y`. + */ +class AddOperation extends BinaryArithmeticOperation, @add_operation { } + +/** + * A subtraction operation, either `x - y` or `x -= y`. + */ +class SubOperation extends BinaryArithmeticOperation, @sub_operation { } + +/** + * A multiplication operation, either `x * y` or `x *= y`. + */ +class MulOperation extends BinaryArithmeticOperation, @mul_operation { } + +/** + * A division operation, either `x / y` or `x /= y`. + */ +class DivOperation extends BinaryArithmeticOperation, @div_operation { + /** Gets the numerator of this division operation. */ + Expr getNumerator() { result = this.getLeftOperand() } + + /** Gets the denominator of this division operation. */ + Expr getDenominator() { result = this.getRightOperand() } +} + +/** + * A remainder operation, either `x % y` or `x %= y`. + */ +class RemOperation extends BinaryArithmeticOperation, @rem_operation { } + /** * A binary arithmetic expression. Either an addition expression * (`AddExpr`), a subtraction expression (`SubExpr`), a multiplication diff --git a/csharp/ql/lib/semmle/code/csharp/exprs/Operation.qll b/csharp/ql/lib/semmle/code/csharp/exprs/Operation.qll index 09258024803..b41fcfb7c7e 100644 --- a/csharp/ql/lib/semmle/code/csharp/exprs/Operation.qll +++ b/csharp/ql/lib/semmle/code/csharp/exprs/Operation.qll @@ -4,45 +4,6 @@ import Expr -/** - * A binary arithmetic operation. Either a binary arithmetic expression (`BinaryArithmeticExpr`) or - * an arithmetic assignment operation (`AssignArithmeticExpr`). - */ -class BinaryArithmeticOperation extends ArithmeticOperation, BinaryOperation, @bin_arith_operation { - override string getOperator() { none() } -} - -/** - * An addition operation, either `x + y` or `x += y`. - */ -class AddOperation extends BinaryArithmeticOperation, @add_operation { } - -/** - * A subtraction operation, either `x - y` or `x -= y`. - */ -class SubOperation extends BinaryArithmeticOperation, @sub_operation { } - -/** - * A multiplication operation, either `x * y` or `x *= y`. - */ -class MulOperation extends BinaryArithmeticOperation, @mul_operation { } - -/** - * A division operation, either `x / y` or `x /= y`. - */ -class DivOperation extends BinaryArithmeticOperation, @div_operation { - /** Gets the numerator of this division operation. */ - Expr getNumerator() { result = this.getLeftOperand() } - - /** Gets the denominator of this division operation. */ - Expr getDenominator() { result = this.getRightOperand() } -} - -/** - * A remainder operation, either `x % y` or `x %= y`. - */ -class RemOperation extends BinaryArithmeticOperation, @rem_operation { } - /** * A bitwise-and operation, either `x & y` or `x &= y`. */