Skip to content

Commit 78b5227

Browse files
committed
C++: Split CoReturnStmt.getExpr into CoReturnStmt.{getOperand,getExpr}
1 parent 8b8b9d6 commit 78b5227

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

  • cpp/ql/src/semmle/code/cpp/stmts

cpp/ql/src/semmle/code/cpp/stmts/Stmt.qll

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -678,20 +678,33 @@ class CoReturnStmt extends Stmt, @stmt_co_return {
678678
override string getAPrimaryQlClass() { result = "CoReturnStmt" }
679679

680680
/**
681-
* Gets the expression of this 'co_return' statement.
681+
* Gets the operand of this 'co_return' statement.
682682
*
683683
* For example, for
684684
* ```
685685
* co_return 1+2;
686686
* ```
687-
* the result is `1+2`, and there is no result for
687+
* the operand is a function call `return_value(1+2)`, and for
688688
* ```
689689
* co_return;
690690
* ```
691+
* the operand is a function call `return_void()`.
692+
*/
693+
FunctionCall getOperand() { result = this.getChild(0) }
694+
695+
/**
696+
* Gets the expression of this 'co_return' statement, if any.
691697
*
692-
* TODO: Really?
698+
* For example, for
699+
* ```
700+
* co_return 1+2;
701+
* ```
702+
* the result is `1+2`, and there is no result for
703+
* ```
704+
* co_return;
705+
* ```
693706
*/
694-
Expr getExpr() { result = this.getChild(0) }
707+
Expr getExpr() { result = this.getOperand().getArgument(0) }
695708

696709
/**
697710
* Holds if this 'co_return' statement has an expression.

0 commit comments

Comments
 (0)