@@ -373,7 +373,7 @@ synthesizeConstantGetterBody(AbstractFunctionDecl *afd, void *voidContext) {
373373 }
374374
375375 // Create the return statement.
376- auto ret = new (ctx) ReturnStmt ( SourceLoc () , expr);
376+ auto ret = ReturnStmt::createImplicit (ctx , expr);
377377
378378 return {BraceStmt::create (ctx, SourceLoc (), ASTNode (ret), SourceLoc ()),
379379 /* isTypeChecked=*/ true };
@@ -471,7 +471,7 @@ synthesizeStructDefaultConstructorBody(AbstractFunctionDecl *afd,
471471 auto assign = new (ctx) AssignExpr (lhs, SourceLoc (), call, /* implicit*/ true );
472472 assign->setType (emptyTuple);
473473
474- auto ret = new (ctx) ReturnStmt ( SourceLoc (), nullptr , /* Implicit= */ true );
474+ auto * ret = ReturnStmt::createImplicit (ctx, /* expr */ nullptr );
475475
476476 // Create the function body.
477477 auto body = BraceStmt::create (ctx, SourceLoc (), {assign, ret}, SourceLoc ());
@@ -565,8 +565,7 @@ synthesizeValueConstructorBody(AbstractFunctionDecl *afd, void *context) {
565565 }
566566 }
567567
568- auto ret = new (ctx) ReturnStmt (SourceLoc (), nullptr , /* Implicit=*/ true );
569- stmts.push_back (ret);
568+ stmts.push_back (ReturnStmt::createImplicit (ctx, /* expr*/ nullptr ));
570569
571570 // Create the function body.
572571 auto body = BraceStmt::create (ctx, SourceLoc (), stmts, SourceLoc ());
@@ -689,7 +688,7 @@ synthesizeRawValueBridgingConstructorBody(AbstractFunctionDecl *afd,
689688 /* Implicit=*/ true );
690689 assign->setType (TupleType::getEmpty (ctx));
691690
692- auto ret = new (ctx) ReturnStmt ( SourceLoc (), nullptr , /* Implicit= */ true );
691+ auto * ret = ReturnStmt::createImplicit (ctx, /* expr */ nullptr );
693692
694693 auto body = BraceStmt::create (ctx, SourceLoc (), {assign, ret}, SourceLoc ());
695694 return {body, /* isTypeChecked=*/ true };
@@ -852,7 +851,7 @@ synthesizeUnionFieldGetterBody(AbstractFunctionDecl *afd, void *context) {
852851 CallExpr::createImplicit (ctx, reinterpretCastRefExpr, argList);
853852 reinterpreted->setType (importedFieldDecl->getInterfaceType ());
854853 reinterpreted->setThrows (nullptr );
855- auto ret = new (ctx) ReturnStmt ( SourceLoc () , reinterpreted);
854+ auto * ret = ReturnStmt::createImplicit (ctx , reinterpreted);
856855 auto body = BraceStmt::create (ctx, SourceLoc (), ASTNode (ret), SourceLoc (),
857856 /* implicit*/ true );
858857 return {body, /* isTypeChecked*/ true };
@@ -1118,7 +1117,7 @@ synthesizeIndirectFieldGetterBody(AbstractFunctionDecl *afd, void *context) {
11181117 DeclNameLoc (), /* implicit*/ true );
11191118 expr->setType (anonymousInnerFieldDecl->getInterfaceType ());
11201119
1121- auto ret = new (ctx) ReturnStmt ( SourceLoc () , expr);
1120+ auto * ret = ReturnStmt::createImplicit (ctx , expr);
11221121 auto body = BraceStmt::create (ctx, SourceLoc (), ASTNode (ret), SourceLoc (),
11231122 /* implicit*/ true );
11241123 return {body, /* isTypeChecked=*/ true };
@@ -1242,7 +1241,7 @@ synthesizeEnumRawValueConstructorBody(AbstractFunctionDecl *afd,
12421241 /* implicit*/ true );
12431242 assign->setType (TupleType::getEmpty (ctx));
12441243
1245- auto ret = new (ctx) ReturnStmt ( SourceLoc (), nullptr , /* Implicit= */ true );
1244+ auto * ret = ReturnStmt::createImplicit (ctx, /* expr */ nullptr );
12461245
12471246 auto body = BraceStmt::create (ctx, SourceLoc (), {assign, ret}, SourceLoc (),
12481247 /* implicit*/ true );
@@ -1310,7 +1309,7 @@ synthesizeEnumRawValueGetterBody(AbstractFunctionDecl *afd, void *context) {
13101309 reinterpreted->setType (rawTy);
13111310 reinterpreted->setThrows (nullptr );
13121311
1313- auto ret = new (ctx) ReturnStmt ( SourceLoc () , reinterpreted);
1312+ auto * ret = ReturnStmt::createImplicit (ctx , reinterpreted);
13141313 auto body = BraceStmt::create (ctx, SourceLoc (), ASTNode (ret), SourceLoc (),
13151314 /* implicit*/ true );
13161315 return {body, /* isTypeChecked=*/ true };
@@ -1380,7 +1379,7 @@ synthesizeStructRawValueGetterBody(AbstractFunctionDecl *afd, void *context) {
13801379 result = CoerceExpr::createImplicit (ctx, bridge, computedType);
13811380 }
13821381
1383- auto ret = new (ctx) ReturnStmt ( SourceLoc () , result);
1382+ auto ret = ReturnStmt::createImplicit (ctx , result);
13841383 auto body = BraceStmt::create (ctx, SourceLoc (), ASTNode (ret), SourceLoc (),
13851384 /* implicit*/ true );
13861385 return {body, /* isTypeChecked=*/ true };
@@ -1565,8 +1564,7 @@ synthesizeUnwrappingGetterOrAddressGetterBody(AbstractFunctionDecl *afd,
15651564 propertyExpr = SwiftDeclSynthesizer::synthesizeReturnReinterpretCast (
15661565 ctx, getterImpl->getResultInterfaceType (), elementTy, propertyExpr);
15671566
1568- auto returnStmt = new (ctx) ReturnStmt (SourceLoc (), propertyExpr,
1569- /* implicit*/ true );
1567+ auto *returnStmt = ReturnStmt::createImplicit (ctx, propertyExpr);
15701568
15711569 auto body = BraceStmt::create (ctx, SourceLoc (), {returnStmt}, SourceLoc (),
15721570 /* implicit*/ true );
@@ -1645,8 +1643,7 @@ synthesizeUnwrappingAddressSetterBody(AbstractFunctionDecl *afd,
16451643 auto *setterImplCallExpr =
16461644 createAccessorImplCallExpr (setterImpl, selfArg, nullptr );
16471645
1648- auto returnStmt = new (ctx) ReturnStmt (SourceLoc (), setterImplCallExpr,
1649- /* implicit*/ true );
1646+ auto *returnStmt = ReturnStmt::createImplicit (ctx, setterImplCallExpr);
16501647
16511648 auto body = BraceStmt::create (ctx, SourceLoc (), {returnStmt}, SourceLoc (),
16521649 /* implicit*/ true );
@@ -1884,8 +1881,7 @@ synthesizeSuccessorFuncBody(AbstractFunctionDecl *afd, void *context) {
18841881 /* implicit*/ true );
18851882 copyRefRValueExpr->setType (copyDecl->getInterfaceType ());
18861883
1887- auto returnStmt = new (ctx) ReturnStmt (SourceLoc (), copyRefRValueExpr,
1888- /* implicit*/ true );
1884+ auto *returnStmt = ReturnStmt::createImplicit (ctx, copyRefRValueExpr);
18891885
18901886 auto body = BraceStmt::create (ctx, SourceLoc (),
18911887 {
@@ -1974,8 +1970,7 @@ synthesizeOperatorMethodBody(AbstractFunctionDecl *afd, void *context) {
19741970 callExpr->setType (funcDecl->getResultInterfaceType ());
19751971 callExpr->setThrows (nullptr );
19761972
1977- auto returnStmt = new (ctx) ReturnStmt (SourceLoc (), callExpr,
1978- /* implicit*/ true );
1973+ auto *returnStmt = ReturnStmt::createImplicit (ctx, callExpr);
19791974
19801975 auto body = BraceStmt::create (ctx, SourceLoc (), {returnStmt}, SourceLoc (),
19811976 /* implicit*/ true );
@@ -2061,10 +2056,9 @@ synthesizeComputedGetterFromCXXMethod(AbstractFunctionDecl *afd,
20612056 auto selfArg = createSelfArg (accessor);
20622057
20632058 auto *getterImplCallExpr = createAccessorImplCallExpr (method, selfArg);
2064- auto returnStmt =
2065- new (method->getASTContext ()) ReturnStmt (SourceLoc (), getterImplCallExpr);
2066- auto body = BraceStmt::create (method->getASTContext (), SourceLoc (),
2067- {returnStmt}, SourceLoc ());
2059+ auto &ctx = method->getASTContext ();
2060+ auto *returnStmt = ReturnStmt::createImplicit (ctx, getterImplCallExpr);
2061+ auto *body = BraceStmt::create (ctx, SourceLoc (), {returnStmt}, SourceLoc ());
20682062
20692063 return {body, /* isTypeChecked*/ true };
20702064}
@@ -2218,8 +2212,7 @@ synthesizeDefaultArgumentBody(AbstractFunctionDecl *afd, void *context) {
22182212 initCall->setThrows (nullptr );
22192213
22202214 // Synthesize `return __cxx__defaultArg_XYZ()`.
2221- auto returnStmt = new (ctx) ReturnStmt (SourceLoc (), initCall,
2222- /* implicit=*/ true );
2215+ auto *returnStmt = ReturnStmt::createImplicit (ctx, initCall);
22232216
22242217 auto body = BraceStmt::create (ctx, SourceLoc (), {returnStmt}, SourceLoc (),
22252218 /* implicit=*/ true );
0 commit comments