Skip to content

Commit 8f22066

Browse files
committed
C#: Update the QL library to reflect the changes to the DB scheme.
1 parent 239683e commit 8f22066

5 files changed

Lines changed: 35 additions & 7 deletions

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ class ArithmeticOperation extends Operation, @arith_op_expr {
2020
* (`UnaryMinusExpr`), a unary plus operation (`UnaryPlusExpr`),
2121
* or a mutator operation (`MutatorOperation`).
2222
*/
23-
class UnaryArithmeticOperation extends ArithmeticOperation, UnaryOperation, @un_arith_op_expr { }
23+
class UnaryArithmeticOperation extends ArithmeticOperation, UnaryCallOperation, @un_arith_op_expr {
24+
}
2425

2526
/**
2627
* A unary minus operation, for example `-x`.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class BitwiseOperation extends Operation, @bit_expr { }
1616
* A unary bitwise operation, that is, a bitwise complement operation
1717
* (`ComplementExpr`).
1818
*/
19-
class UnaryBitwiseOperation extends BitwiseOperation, UnaryOperation, @un_bit_op_expr { }
19+
class UnaryBitwiseOperation extends BitwiseOperation, UnaryCallOperation, @un_bit_op_expr { }
2020

2121
/**
2222
* A bitwise complement operation, for example `~x`.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ class ExtensionOperatorCall extends OperatorCall {
545545
}
546546

547547
/**
548-
* A call to a user-defined mutator operator, for example `a++` on
548+
* A call to a mutator operator, for example `a++` on
549549
* line 7 in
550550
*
551551
* ```csharp
@@ -560,7 +560,7 @@ class ExtensionOperatorCall extends OperatorCall {
560560
* }
561561
* ```
562562
*/
563-
class MutatorOperatorCall extends OperatorCall {
563+
class MutatorOperatorCall extends MutatorOperation {
564564
MutatorOperatorCall() { mutator_invocation_mode(this, _) }
565565

566566
/** Holds if the operator is in prefix position. */

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,33 @@ class UnaryOperation extends Operation, @un_op {
234234
override string toString() { result = this.getOperator() + "..." }
235235
}
236236

237+
/**
238+
* A unary operator call. Either a unary arithmetic operator call (`UnaryArithmeticOperatorCall`),
239+
* a unary bitwise operator call (`UnaryBitwiseOperatorCall`), or a
240+
* unary logical operator call (`UnaryLogicalOperatorCall`).
241+
*/
242+
class UnaryCallOperation extends OperatorCall, UnaryOperation, @un_op_call_expr {
243+
override string toString() { result = UnaryOperation.super.toString() }
244+
}
245+
246+
/**
247+
* A logical 'not', for example `!String.IsNullOrEmpty(s)` or a call to a user-defined
248+
* not operator such as `!x` in:
249+
* ```csharp
250+
* class Negatable {
251+
* public static Negatable operator !(Negatable n) => { ...};
252+
* }
253+
*
254+
* var x = new Negatable();
255+
* var y = !x;
256+
* ```
257+
*/
258+
class UnaryNotOperation extends UnaryCallOperation, @un_not_op_expr {
259+
override string getOperator() { result = "!" }
260+
261+
override string getAPrimaryQlClass() { result = "UnaryNotOperation" }
262+
}
263+
237264
/**
238265
* A binary operation. Either a binary arithmetic operation
239266
* (`BinaryArithmeticOperation`), a binary bitwise operation

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ class LogicalOperation extends Operation, @log_expr {
1818
/**
1919
* A unary logical operation, that is, a logical 'not' (`LogicalNotExpr`).
2020
*/
21-
class UnaryLogicalOperation extends LogicalOperation, UnaryOperation, @un_log_op_expr { }
21+
class UnaryLogicalOperation extends LogicalOperation, UnaryCallOperation, @un_log_op_expr { }
2222

2323
/**
2424
* A logical 'not', for example `!String.IsNullOrEmpty(s)`.
2525
*/
26-
class LogicalNotExpr extends UnaryLogicalOperation, @log_not_expr {
27-
override string getOperator() { result = "!" }
26+
class LogicalNotExpr extends UnaryLogicalOperation, UnaryNotOperation, @log_not_expr {
27+
override string getOperator() { result = UnaryNotOperation.super.getOperator() }
2828

2929
override string getAPrimaryQlClass() { result = "LogicalNotExpr" }
3030
}

0 commit comments

Comments
 (0)