@@ -70,6 +70,7 @@ namespace swift {
7070 class CallExpr ;
7171 class KeyPathExpr ;
7272 class CaptureListExpr ;
73+ class ThenStmt ;
7374
7475enum class ExprKind : uint8_t {
7576#define EXPR (Id, Parent ) Id,
@@ -6125,10 +6126,10 @@ class SingleValueStmtExpr : public Expr {
61256126 SingleValueStmtExpr (Stmt *S, DeclContext *DC)
61266127 : Expr(ExprKind::SingleValueStmt, /* isImplicit*/ true ), S(S), DC(DC) {}
61276128
6128- public:
61296129 // / Creates a new SingleValueStmtExpr wrapping a statement.
61306130 static SingleValueStmtExpr *create (ASTContext &ctx, Stmt *S, DeclContext *DC);
61316131
6132+ public:
61326133 // / Creates a new SingleValueStmtExpr wrapping a statement, and recursively
61336134 // / attempts to wrap any branches of that statement that can become single
61346135 // / value statement expressions.
@@ -6144,6 +6145,16 @@ class SingleValueStmtExpr : public Expr {
61446145 // / SingleValueStmtExpr.
61456146 static SingleValueStmtExpr *tryDigOutSingleValueStmtExpr (Expr *E);
61466147
6148+ // / Retrieves a resulting ThenStmt from the given BraceStmt, or \c nullptr if
6149+ // / the brace does not have a resulting ThenStmt.
6150+ static ThenStmt *getThenStmtFrom (BraceStmt *BS);
6151+
6152+ // / Whether the given BraceStmt has a result to be produced from a parent
6153+ // / SingleValueStmtExpr.
6154+ static bool hasResult (BraceStmt *BS) {
6155+ return getThenStmtFrom (BS);
6156+ }
6157+
61476158 // / Retrieve the wrapped statement.
61486159 Stmt *getStmt () const { return S; }
61496160 void setStmt (Stmt *newS) { S = newS; }
@@ -6154,10 +6165,15 @@ class SingleValueStmtExpr : public Expr {
61546165 // / Retrieve the complete set of branches for the underlying statement.
61556166 ArrayRef<Stmt *> getBranches (SmallVectorImpl<Stmt *> &scratch) const ;
61566167
6157- // / Retrieve the single expression branches of the statement, excluding
6158- // / branches that either have multiple expressions, or have statements.
6168+ // / Retrieve the resulting ThenStmts from each branch of the
6169+ // / SingleValueStmtExpr.
6170+ ArrayRef<ThenStmt *>
6171+ getThenStmts (SmallVectorImpl<ThenStmt *> &scratch) const ;
6172+
6173+ // / Retrieve the result expressions from each branch of the
6174+ // / SingleValueStmtExpr.
61596175 ArrayRef<Expr *>
6160- getSingleExprBranches (SmallVectorImpl<Expr *> &scratch) const ;
6176+ getResultExprs (SmallVectorImpl<Expr *> &scratch) const ;
61616177
61626178 DeclContext *getDeclContext () const { return DC; }
61636179
0 commit comments