@@ -373,7 +373,7 @@ synthesizeConstantGetterBody(AbstractFunctionDecl *afd, void *voidContext) {
373
373
}
374
374
375
375
// Create the return statement.
376
- auto ret = new (ctx) ReturnStmt ( SourceLoc () , expr);
376
+ auto ret = ReturnStmt::createImplicit (ctx , expr);
377
377
378
378
return {BraceStmt::create (ctx, SourceLoc (), ASTNode (ret), SourceLoc ()),
379
379
/* isTypeChecked=*/ true };
@@ -471,7 +471,7 @@ synthesizeStructDefaultConstructorBody(AbstractFunctionDecl *afd,
471
471
auto assign = new (ctx) AssignExpr (lhs, SourceLoc (), call, /* implicit*/ true );
472
472
assign->setType (emptyTuple);
473
473
474
- auto ret = new (ctx) ReturnStmt ( SourceLoc (), nullptr , /* Implicit= */ true );
474
+ auto * ret = ReturnStmt::createImplicit (ctx, /* expr */ nullptr );
475
475
476
476
// Create the function body.
477
477
auto body = BraceStmt::create (ctx, SourceLoc (), {assign, ret}, SourceLoc ());
@@ -565,8 +565,7 @@ synthesizeValueConstructorBody(AbstractFunctionDecl *afd, void *context) {
565
565
}
566
566
}
567
567
568
- auto ret = new (ctx) ReturnStmt (SourceLoc (), nullptr , /* Implicit=*/ true );
569
- stmts.push_back (ret);
568
+ stmts.push_back (ReturnStmt::createImplicit (ctx, /* expr*/ nullptr ));
570
569
571
570
// Create the function body.
572
571
auto body = BraceStmt::create (ctx, SourceLoc (), stmts, SourceLoc ());
@@ -689,7 +688,7 @@ synthesizeRawValueBridgingConstructorBody(AbstractFunctionDecl *afd,
689
688
/* Implicit=*/ true );
690
689
assign->setType (TupleType::getEmpty (ctx));
691
690
692
- auto ret = new (ctx) ReturnStmt ( SourceLoc (), nullptr , /* Implicit= */ true );
691
+ auto * ret = ReturnStmt::createImplicit (ctx, /* expr */ nullptr );
693
692
694
693
auto body = BraceStmt::create (ctx, SourceLoc (), {assign, ret}, SourceLoc ());
695
694
return {body, /* isTypeChecked=*/ true };
@@ -852,7 +851,7 @@ synthesizeUnionFieldGetterBody(AbstractFunctionDecl *afd, void *context) {
852
851
CallExpr::createImplicit (ctx, reinterpretCastRefExpr, argList);
853
852
reinterpreted->setType (importedFieldDecl->getInterfaceType ());
854
853
reinterpreted->setThrows (nullptr );
855
- auto ret = new (ctx) ReturnStmt ( SourceLoc () , reinterpreted);
854
+ auto * ret = ReturnStmt::createImplicit (ctx , reinterpreted);
856
855
auto body = BraceStmt::create (ctx, SourceLoc (), ASTNode (ret), SourceLoc (),
857
856
/* implicit*/ true );
858
857
return {body, /* isTypeChecked*/ true };
@@ -1118,7 +1117,7 @@ synthesizeIndirectFieldGetterBody(AbstractFunctionDecl *afd, void *context) {
1118
1117
DeclNameLoc (), /* implicit*/ true );
1119
1118
expr->setType (anonymousInnerFieldDecl->getInterfaceType ());
1120
1119
1121
- auto ret = new (ctx) ReturnStmt ( SourceLoc () , expr);
1120
+ auto * ret = ReturnStmt::createImplicit (ctx , expr);
1122
1121
auto body = BraceStmt::create (ctx, SourceLoc (), ASTNode (ret), SourceLoc (),
1123
1122
/* implicit*/ true );
1124
1123
return {body, /* isTypeChecked=*/ true };
@@ -1242,7 +1241,7 @@ synthesizeEnumRawValueConstructorBody(AbstractFunctionDecl *afd,
1242
1241
/* implicit*/ true );
1243
1242
assign->setType (TupleType::getEmpty (ctx));
1244
1243
1245
- auto ret = new (ctx) ReturnStmt ( SourceLoc (), nullptr , /* Implicit= */ true );
1244
+ auto * ret = ReturnStmt::createImplicit (ctx, /* expr */ nullptr );
1246
1245
1247
1246
auto body = BraceStmt::create (ctx, SourceLoc (), {assign, ret}, SourceLoc (),
1248
1247
/* implicit*/ true );
@@ -1310,7 +1309,7 @@ synthesizeEnumRawValueGetterBody(AbstractFunctionDecl *afd, void *context) {
1310
1309
reinterpreted->setType (rawTy);
1311
1310
reinterpreted->setThrows (nullptr );
1312
1311
1313
- auto ret = new (ctx) ReturnStmt ( SourceLoc () , reinterpreted);
1312
+ auto * ret = ReturnStmt::createImplicit (ctx , reinterpreted);
1314
1313
auto body = BraceStmt::create (ctx, SourceLoc (), ASTNode (ret), SourceLoc (),
1315
1314
/* implicit*/ true );
1316
1315
return {body, /* isTypeChecked=*/ true };
@@ -1380,7 +1379,7 @@ synthesizeStructRawValueGetterBody(AbstractFunctionDecl *afd, void *context) {
1380
1379
result = CoerceExpr::createImplicit (ctx, bridge, computedType);
1381
1380
}
1382
1381
1383
- auto ret = new (ctx) ReturnStmt ( SourceLoc () , result);
1382
+ auto ret = ReturnStmt::createImplicit (ctx , result);
1384
1383
auto body = BraceStmt::create (ctx, SourceLoc (), ASTNode (ret), SourceLoc (),
1385
1384
/* implicit*/ true );
1386
1385
return {body, /* isTypeChecked=*/ true };
@@ -1565,8 +1564,7 @@ synthesizeUnwrappingGetterOrAddressGetterBody(AbstractFunctionDecl *afd,
1565
1564
propertyExpr = SwiftDeclSynthesizer::synthesizeReturnReinterpretCast (
1566
1565
ctx, getterImpl->getResultInterfaceType (), elementTy, propertyExpr);
1567
1566
1568
- auto returnStmt = new (ctx) ReturnStmt (SourceLoc (), propertyExpr,
1569
- /* implicit*/ true );
1567
+ auto *returnStmt = ReturnStmt::createImplicit (ctx, propertyExpr);
1570
1568
1571
1569
auto body = BraceStmt::create (ctx, SourceLoc (), {returnStmt}, SourceLoc (),
1572
1570
/* implicit*/ true );
@@ -1645,8 +1643,7 @@ synthesizeUnwrappingAddressSetterBody(AbstractFunctionDecl *afd,
1645
1643
auto *setterImplCallExpr =
1646
1644
createAccessorImplCallExpr (setterImpl, selfArg, nullptr );
1647
1645
1648
- auto returnStmt = new (ctx) ReturnStmt (SourceLoc (), setterImplCallExpr,
1649
- /* implicit*/ true );
1646
+ auto *returnStmt = ReturnStmt::createImplicit (ctx, setterImplCallExpr);
1650
1647
1651
1648
auto body = BraceStmt::create (ctx, SourceLoc (), {returnStmt}, SourceLoc (),
1652
1649
/* implicit*/ true );
@@ -1884,8 +1881,7 @@ synthesizeSuccessorFuncBody(AbstractFunctionDecl *afd, void *context) {
1884
1881
/* implicit*/ true );
1885
1882
copyRefRValueExpr->setType (copyDecl->getInterfaceType ());
1886
1883
1887
- auto returnStmt = new (ctx) ReturnStmt (SourceLoc (), copyRefRValueExpr,
1888
- /* implicit*/ true );
1884
+ auto *returnStmt = ReturnStmt::createImplicit (ctx, copyRefRValueExpr);
1889
1885
1890
1886
auto body = BraceStmt::create (ctx, SourceLoc (),
1891
1887
{
@@ -1974,8 +1970,7 @@ synthesizeOperatorMethodBody(AbstractFunctionDecl *afd, void *context) {
1974
1970
callExpr->setType (funcDecl->getResultInterfaceType ());
1975
1971
callExpr->setThrows (nullptr );
1976
1972
1977
- auto returnStmt = new (ctx) ReturnStmt (SourceLoc (), callExpr,
1978
- /* implicit*/ true );
1973
+ auto *returnStmt = ReturnStmt::createImplicit (ctx, callExpr);
1979
1974
1980
1975
auto body = BraceStmt::create (ctx, SourceLoc (), {returnStmt}, SourceLoc (),
1981
1976
/* implicit*/ true );
@@ -2061,10 +2056,9 @@ synthesizeComputedGetterFromCXXMethod(AbstractFunctionDecl *afd,
2061
2056
auto selfArg = createSelfArg (accessor);
2062
2057
2063
2058
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 ());
2068
2062
2069
2063
return {body, /* isTypeChecked*/ true };
2070
2064
}
@@ -2218,8 +2212,7 @@ synthesizeDefaultArgumentBody(AbstractFunctionDecl *afd, void *context) {
2218
2212
initCall->setThrows (nullptr );
2219
2213
2220
2214
// Synthesize `return __cxx__defaultArg_XYZ()`.
2221
- auto returnStmt = new (ctx) ReturnStmt (SourceLoc (), initCall,
2222
- /* implicit=*/ true );
2215
+ auto *returnStmt = ReturnStmt::createImplicit (ctx, initCall);
2223
2216
2224
2217
auto body = BraceStmt::create (ctx, SourceLoc (), {returnStmt}, SourceLoc (),
2225
2218
/* implicit=*/ true );
0 commit comments