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

Skip to content

Commit 5df5e6d

Browse files
Matthew Gretton-Dannigfoo
authored andcommitted
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`.
1 parent 8199b3a commit 5df5e6d

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,3 +1268,32 @@ class SpaceshipExpr extends BinaryOperation, @spaceshipexpr {
12681268

12691269
override string getOperator() { result = "<=>" }
12701270
}
1271+
1272+
/**
1273+
* A C/C++ co_await expression
1274+
* ```
1275+
* co_await foo();
1276+
* ```
1277+
*/
1278+
class CoAwaitExpr extends UnaryOperation, @co_await {
1279+
override string getAPrimaryQlClass() { result = "CoAwaitExpr" }
1280+
1281+
override string getOperator() { result = "co_await" }
1282+
1283+
override int getPrecedence() { result = 16 }
1284+
}
1285+
1286+
1287+
/**
1288+
* A C/C++ co_yield expression
1289+
* ```
1290+
* co_yield 1;
1291+
* ```
1292+
*/
1293+
class CoYieldExpr extends UnaryOperation, @co_yield {
1294+
override string getAPrimaryQlClass() { result = "CoYieldExpr" }
1295+
1296+
override string getOperator() { result = "co_yield" }
1297+
1298+
override int getPrecedence() { result = 2 }
1299+
}

cpp/ql/src/semmlecode.cpp.dbscheme

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1857,6 +1857,8 @@ case @stmt.kind of
18571857
| 38 = @stmt_range_based_for_co_await
18581858
;
18591859

1860+
@range_based_for_stmt = @stmt_range_based_for | @stmt_range_based_for_co_await;
1861+
18601862
type_vla(
18611863
int type_id: @type ref,
18621864
int decl: @stmt_vla_decl ref

0 commit comments

Comments
 (0)