C++: Remove abstract classes from unary operations

This commit is contained in:
Mathias Vorreiter Pedersen
2019-12-20 15:19:08 +01:00
parent 18d4772508
commit 006c8bb0cd
5 changed files with 30 additions and 11 deletions

View File

@@ -3,9 +3,9 @@ import semmle.code.cpp.exprs.Expr
/**
* A C/C++ unary arithmetic operation.
*
* This is an abstract base QL class.
* This is an base QL class.
*/
abstract class UnaryArithmeticOperation extends UnaryOperation { }
class UnaryArithmeticOperation extends UnaryOperation, @un_arith_op_expr { }
/**
* A C/C++ unary minus expression.
@@ -53,12 +53,12 @@ class ConjugationExpr extends UnaryArithmeticOperation, @conjugation {
/**
* A C/C++ `++` or `--` expression (either prefix or postfix).
*
* This is the abstract base QL class for increment and decrement operations.
* This is the base QL class for increment and decrement operations.
*
* Note that this does not include calls to user-defined `operator++`
* or `operator--`.
*/
abstract class CrementOperation extends UnaryArithmeticOperation {
class CrementOperation extends UnaryArithmeticOperation, @crement_op_expr {
override predicate mayBeImpure() { any() }
override predicate mayBeGloballyImpure() {
@@ -75,28 +75,28 @@ abstract class CrementOperation extends UnaryArithmeticOperation {
*
* Note that this does not include calls to user-defined `operator++`.
*/
abstract class IncrementOperation extends CrementOperation { }
class IncrementOperation extends CrementOperation, @incr_oper_expr { }
/**
* A C/C++ `--` expression (either prefix or postfix).
*
* Note that this does not include calls to user-defined `operator--`.
*/
abstract class DecrementOperation extends CrementOperation { }
class DecrementOperation extends CrementOperation, @decr_oper_expr { }
/**
* A C/C++ `++` or `--` prefix expression.
*
* Note that this does not include calls to user-defined operators.
*/
abstract class PrefixCrementOperation extends CrementOperation { }
class PrefixCrementOperation extends CrementOperation, @prefix_crement_oper_expr { }
/**
* A C/C++ `++` or `--` postfix expression.
*
* Note that this does not include calls to user-defined operators.
*/
abstract class PostfixCrementOperation extends CrementOperation { }
class PostfixCrementOperation extends CrementOperation, @postfix_crement_oper_expr { }
/**
* A C/C++ prefix increment expression, as in `++x`.

View File

@@ -3,7 +3,7 @@ import semmle.code.cpp.exprs.Expr
/**
* A C/C++ unary bitwise operation.
*/
abstract class UnaryBitwiseOperation extends UnaryOperation { }
class UnaryBitwiseOperation extends UnaryOperation, @un_bitwise_op_expr { }
/**
* A C/C++ complement expression.

View File

@@ -465,7 +465,7 @@ class Expr extends StmtParent, @expr {
*/
abstract class Operation extends Expr {
/** Gets the operator of this operation. */
abstract string getOperator();
string getOperator() { none() }
/** Gets an operand of this operation. */
Expr getAnOperand() { result = this.getAChild() }

View File

@@ -3,7 +3,7 @@ import semmle.code.cpp.exprs.Expr
/**
* A C/C++ unary logical operation.
*/
abstract class UnaryLogicalOperation extends UnaryOperation { }
class UnaryLogicalOperation extends UnaryOperation, @un_log_op_expr { }
/**
* A C/C++ logical not expression.

View File

@@ -1190,6 +1190,25 @@ funbind(
| @delete_expr
| @delete_array_expr;
@prefix_crement_oper_expr = @preincrexpr | @predecrexpr
@postfix_crement_oper_expr = @postincrexpr | @postdecrexpr
@incr_oper_expr = @preincrexpr | @postincrexpr
@decr_oper_expr = @predecrexpr | @postdecrexpr
@crement_op_expr = @incr_oper_expr | @decr_oper_expr | @prefix_crement_oper_expr | @postfix_crement_oper_expr
@un_arith_op_expr = @arithnegexpr | @unaryplusexpr | @conjugation | @realpartexpr | @imagpartexpr | @crement_op_expr
@un_bitwise_op_expr = @complementexpr
@un_log_op_expr = @notexpr
@un_op_expr = @address_of | @indirect | @un_arith_op_expr | @un_bitwise_op_expr | @builtinaddressof | @vec_fill | @un_log_op_expr
/*
case @allocator.form of
0 = plain