[AST] Remove the "single expression body" bit

Remove this bit from function decls and closures.
Instead, for closures, infer it from the presence
of a single return or single expression AST node
in the body, which ought to be equivalent, and
automatically takes result builders into
consideration. We can also completely drop this
query from AbstractFunctionDecl, replacing it
instead with a bit on ReturnStmt.
This commit is contained in:
Hamish Knight
2024-01-30 14:08:54 +00:00
parent 9cf8f5b1f0
commit 9b64990d24
25 changed files with 160 additions and 161 deletions

View File

@@ -279,7 +279,7 @@ private:
ASTNode ClosureElements[] = {OriginalExpr, CheckExpectExpr};
auto *ClosureBody = BraceStmt::create(Ctx, SourceLoc(), ClosureElements,
SourceLoc(), /*Implicit=*/true);
Closure->setBody(ClosureBody, /*isSingleExpression=*/false);
Closure->setBody(ClosureBody);
// Call the closure.
auto *ClosureCall = CallExpr::createImplicitEmpty(Ctx, Closure);