Compare commits

...

7 Commits

Author SHA1 Message Date
Ian Lynagh
62cbd2506c C++: Update stats to add coroutines 2020-09-01 11:48:00 +01:00
Ian Lynagh
ce9432edda C++: Add an upgrade script 2020-08-28 13:52:54 +01:00
Ian Lynagh
8d67418870 C++: Remove co_await range-based-for support for now
Initial impl won't support it
2020-08-28 13:52:54 +01:00
Ian Lynagh
7068a2b5be C++: Split CoReturnStmt.getExpr into CoReturnStmt.{getOperand,getExpr} 2020-08-28 13:52:54 +01:00
Matthew Gretton-Dann
0e9fefd383 Actually sort add Statement support
This commit fixes the previous one.
2020-08-28 13:52:54 +01:00
Matthew Gretton-Dann
79a91bb2a2 Add initial QL support classes for coroutines
Add classes for expressions co_yield and co_await.
Adds classes for statements co_return and `for co_await`.
2020-08-28 13:52:54 +01:00
Matthew Gretton-Dann
c3efacf2df C++: Add DB schema support for coroutines 2020-08-28 13:52:54 +01:00
7 changed files with 5863 additions and 1577 deletions

View File

@@ -1268,3 +1268,32 @@ class SpaceshipExpr extends BinaryOperation, @spaceshipexpr {
override string getOperator() { result = "<=>" }
}
/**
* A C/C++ co_await expression
* ```
* co_await foo();
* ```
*/
class CoAwaitExpr extends UnaryOperation, @co_await {
override string getAPrimaryQlClass() { result = "CoAwaitExpr" }
override string getOperator() { result = "co_await" }
override int getPrecedence() { result = 16 }
}
/**
* A C/C++ co_yield expression
* ```
* co_yield 1;
* ```
*/
class CoYieldExpr extends UnaryOperation, @co_yield {
override string getAPrimaryQlClass() { result = "CoYieldExpr" }
override string getOperator() { result = "co_yield" }
override int getPrecedence() { result = 2 }
}

View File

@@ -662,6 +662,67 @@ class LabelStmt extends Stmt, @stmt_label {
override predicate mayBeGloballyImpure() { none() }
}
/**
* A C/C++ 'co_return' statement.
*
* For example:
* ```
* co_return 1+2;
* ```
* or
* ```
* co_return;
* ```
*/
class CoReturnStmt extends Stmt, @stmt_co_return {
override string getAPrimaryQlClass() { result = "CoReturnStmt" }
/**
* Gets the operand of this 'co_return' statement.
*
* For example, for
* ```
* co_return 1+2;
* ```
* the operand is a function call `return_value(1+2)`, and for
* ```
* co_return;
* ```
* the operand is a function call `return_void()`.
*/
FunctionCall getOperand() { result = this.getChild(0) }
/**
* Gets the expression of this 'co_return' statement, if any.
*
* For example, for
* ```
* co_return 1+2;
* ```
* the result is `1+2`, and there is no result for
* ```
* co_return;
* ```
*/
Expr getExpr() { result = this.getOperand().getArgument(0) }
/**
* Holds if this 'co_return' statement has an expression.
*
* For example, this holds for
* ```
* co_return 1+2;
* ```
* but not for
* ```
* co_return;
* ```
*/
predicate hasExpr() { exists(this.getExpr()) }
override string toString() { result = "co_return ..." }
}
/**
* A C/C++ 'return' statement.
*

View File

@@ -1228,6 +1228,8 @@ funbind(
| @builtinaddressof
| @vec_fill
| @un_log_op_expr
| @co_await
| @co_yield
;
@bin_log_op_expr = @andlogicalexpr | @orlogicalexpr;
@@ -1647,6 +1649,8 @@ case @expr.kind of
| 324 = @builtinconvertvector
| 325 = @builtincomplex
| 326 = @spaceshipexpr
| 327 = @co_await
| 328 = @co_yield
;
@var_args_expr = @vastartexpr
@@ -1851,6 +1855,7 @@ case @stmt.kind of
| 33 = @stmt_handler
// ... 34 @stmt_finally_end deprecated
| 35 = @stmt_constexpr_if
| 37 = @stmt_co_return
;
type_vla(

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,3 @@
description: Add some coroutines types (@co_await, @co_yield, @stmt_co_return)
compatibility: backwards