Actually sort add Statement support

This commit fixes the previous one.
This commit is contained in:
Matthew Gretton-Dann
2020-08-17 17:00:33 +01:00
committed by Ian Lynagh
parent 5df5e6dfce
commit 8b8b9d6fe3
2 changed files with 62 additions and 2 deletions

View File

@@ -380,7 +380,7 @@ class ConstexprIfStmt extends ConditionalStmt, @stmt_constexpr_if {
}
}
private class TLoop = @stmt_while or @stmt_end_test_while or @stmt_range_based_for or @stmt_for;
private class TLoop = @stmt_while or @stmt_end_test_while or @range_based_for_stmt or @stmt_for;
/**
* A C/C++ loop, that is, either a 'while' loop, a 'for' loop, or a
@@ -662,6 +662,54 @@ 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 expression of this 'co_return' statement.
*
* For example, for
* ```
* co_return 1+2;
* ```
* the result is `1+2`, and there is no result for
* ```
* co_return;
* ```
*
* TODO: Really?
*/
Expr getExpr() { result = this.getChild(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.
*
@@ -771,7 +819,7 @@ class DoStmt extends Loop, @stmt_end_test_while {
* ```
* where `begin_expr` and `end_expr` depend on the type of `xs`.
*/
class RangeBasedForStmt extends Loop, @stmt_range_based_for {
class RangeBasedForStmt extends Loop, @range_based_for_stmt {
override string getAPrimaryQlClass() { result = "RangeBasedForStmt" }
/**
@@ -847,6 +895,16 @@ class RangeBasedForStmt extends Loop, @stmt_range_based_for {
LocalVariable getAnIterationVariable() { result = getBeginVariable() }
}
/**
* A C/C++ 'for await' statement.
*
* This represents a range-based 'for await' statement.
class RangeBasedForAwaitStmt extends Loop, @stmt_range_based_for_co_await {
override string getAPrimaryQlClass() { result = "RangeBasedForAwaitStmt" }
override string toString() { result = "for co_await(...:...) ..." }
}
/**
* A C/C++ 'for' 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;