mirror of
https://github.com/github/codeql.git
synced 2025-12-20 18:56:32 +01:00
C++: Add support for the spaceship operator
This commit is contained in:
@@ -1216,3 +1216,18 @@ private predicate constantTemplateLiteral(Expr e) {
|
|||||||
or
|
or
|
||||||
constantTemplateLiteral(e.(Cast).getExpr())
|
constantTemplateLiteral(e.(Cast).getExpr())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A C++ three-way comparison operation, also known as the _spaceship
|
||||||
|
* operation_. This is specific to C++20 and later.
|
||||||
|
* ```
|
||||||
|
* auto c = (a <=> b);
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
class SpaceshipExpr extends BinaryOperation, @spaceshipexpr {
|
||||||
|
override string getCanonicalQLClass() { result = "SpaceshipExpr" }
|
||||||
|
|
||||||
|
override int getPrecedence() { result = 11 }
|
||||||
|
|
||||||
|
override string getOperator() { result = "<=>" }
|
||||||
|
}
|
||||||
|
|||||||
@@ -1231,6 +1231,7 @@ funbind(
|
|||||||
| @ltexpr
|
| @ltexpr
|
||||||
| @geexpr
|
| @geexpr
|
||||||
| @leexpr
|
| @leexpr
|
||||||
|
| @spaceshipexpr
|
||||||
;
|
;
|
||||||
|
|
||||||
@bin_bitwise_op_expr = @lshiftexpr
|
@bin_bitwise_op_expr = @lshiftexpr
|
||||||
@@ -1636,6 +1637,7 @@ case @expr.kind of
|
|||||||
| 323 = @vec_fill
|
| 323 = @vec_fill
|
||||||
| 324 = @builtinconvertvector
|
| 324 = @builtinconvertvector
|
||||||
| 325 = @builtincomplex
|
| 325 = @builtincomplex
|
||||||
|
| 326 = @spaceshipexpr
|
||||||
;
|
;
|
||||||
|
|
||||||
new_allocated_type(
|
new_allocated_type(
|
||||||
|
|||||||
Reference in New Issue
Block a user