C++: Add support for the spaceship operator

This commit is contained in:
Matthew Gretton-Dann
2020-03-02 16:19:31 +00:00
parent c5b3df1eb2
commit 06accfe72b
2 changed files with 17 additions and 0 deletions

View File

@@ -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 = "<=>" }
}

View File

@@ -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(