Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 006c8bb

Browse files
committed
C++: Remove abstract classes from unary operations
1 parent 18d4772 commit 006c8bb

5 files changed

Lines changed: 30 additions & 11 deletions

File tree

cpp/ql/src/semmle/code/cpp/exprs/ArithmeticOperation.qll

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import semmle.code.cpp.exprs.Expr
33
/**
44
* A C/C++ unary arithmetic operation.
55
*
6-
* This is an abstract base QL class.
6+
* This is an base QL class.
77
*/
8-
abstract class UnaryArithmeticOperation extends UnaryOperation { }
8+
class UnaryArithmeticOperation extends UnaryOperation, @un_arith_op_expr { }
99

1010
/**
1111
* A C/C++ unary minus expression.
@@ -53,12 +53,12 @@ class ConjugationExpr extends UnaryArithmeticOperation, @conjugation {
5353
/**
5454
* A C/C++ `++` or `--` expression (either prefix or postfix).
5555
*
56-
* This is the abstract base QL class for increment and decrement operations.
56+
* This is the base QL class for increment and decrement operations.
5757
*
5858
* Note that this does not include calls to user-defined `operator++`
5959
* or `operator--`.
6060
*/
61-
abstract class CrementOperation extends UnaryArithmeticOperation {
61+
class CrementOperation extends UnaryArithmeticOperation, @crement_op_expr {
6262
override predicate mayBeImpure() { any() }
6363

6464
override predicate mayBeGloballyImpure() {
@@ -75,28 +75,28 @@ abstract class CrementOperation extends UnaryArithmeticOperation {
7575
*
7676
* Note that this does not include calls to user-defined `operator++`.
7777
*/
78-
abstract class IncrementOperation extends CrementOperation { }
78+
class IncrementOperation extends CrementOperation, @incr_oper_expr { }
7979

8080
/**
8181
* A C/C++ `--` expression (either prefix or postfix).
8282
*
8383
* Note that this does not include calls to user-defined `operator--`.
8484
*/
85-
abstract class DecrementOperation extends CrementOperation { }
85+
class DecrementOperation extends CrementOperation, @decr_oper_expr { }
8686

8787
/**
8888
* A C/C++ `++` or `--` prefix expression.
8989
*
9090
* Note that this does not include calls to user-defined operators.
9191
*/
92-
abstract class PrefixCrementOperation extends CrementOperation { }
92+
class PrefixCrementOperation extends CrementOperation, @prefix_crement_oper_expr { }
9393

9494
/**
9595
* A C/C++ `++` or `--` postfix expression.
9696
*
9797
* Note that this does not include calls to user-defined operators.
9898
*/
99-
abstract class PostfixCrementOperation extends CrementOperation { }
99+
class PostfixCrementOperation extends CrementOperation, @postfix_crement_oper_expr { }
100100

101101
/**
102102
* A C/C++ prefix increment expression, as in `++x`.

cpp/ql/src/semmle/code/cpp/exprs/BitwiseOperation.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import semmle.code.cpp.exprs.Expr
33
/**
44
* A C/C++ unary bitwise operation.
55
*/
6-
abstract class UnaryBitwiseOperation extends UnaryOperation { }
6+
class UnaryBitwiseOperation extends UnaryOperation, @un_bitwise_op_expr { }
77

88
/**
99
* A C/C++ complement expression.

cpp/ql/src/semmle/code/cpp/exprs/Expr.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ class Expr extends StmtParent, @expr {
465465
*/
466466
abstract class Operation extends Expr {
467467
/** Gets the operator of this operation. */
468-
abstract string getOperator();
468+
string getOperator() { none() }
469469

470470
/** Gets an operand of this operation. */
471471
Expr getAnOperand() { result = this.getAChild() }

cpp/ql/src/semmle/code/cpp/exprs/LogicalOperation.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import semmle.code.cpp.exprs.Expr
33
/**
44
* A C/C++ unary logical operation.
55
*/
6-
abstract class UnaryLogicalOperation extends UnaryOperation { }
6+
class UnaryLogicalOperation extends UnaryOperation, @un_log_op_expr { }
77

88
/**
99
* A C/C++ logical not expression.

cpp/ql/src/semmlecode.cpp.dbscheme

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,6 +1190,25 @@ funbind(
11901190
| @delete_expr
11911191
| @delete_array_expr;
11921192

1193+
1194+
@prefix_crement_oper_expr = @preincrexpr | @predecrexpr
1195+
1196+
@postfix_crement_oper_expr = @postincrexpr | @postdecrexpr
1197+
1198+
@incr_oper_expr = @preincrexpr | @postincrexpr
1199+
1200+
@decr_oper_expr = @predecrexpr | @postdecrexpr
1201+
1202+
@crement_op_expr = @incr_oper_expr | @decr_oper_expr | @prefix_crement_oper_expr | @postfix_crement_oper_expr
1203+
1204+
@un_arith_op_expr = @arithnegexpr | @unaryplusexpr | @conjugation | @realpartexpr | @imagpartexpr | @crement_op_expr
1205+
1206+
@un_bitwise_op_expr = @complementexpr
1207+
1208+
@un_log_op_expr = @notexpr
1209+
1210+
@un_op_expr = @address_of | @indirect | @un_arith_op_expr | @un_bitwise_op_expr | @builtinaddressof | @vec_fill | @un_log_op_expr
1211+
11931212
/*
11941213
case @allocator.form of
11951214
0 = plain

0 commit comments

Comments
 (0)