@@ -6328,7 +6328,30 @@ ParserResult<FuncDecl> Parser::parseDeclFunc(SourceLoc StaticLoc,
6328
6328
return DCC.fixupParserResult (FD);
6329
6329
}
6330
6330
6331
- // / Parse function body into \p AFD.
6331
+ // / Parse a function body for \p AFD and returns it without setting the body
6332
+ // / to \p AFD .
6333
+ ParserResult<BraceStmt>
6334
+ Parser::parseAbstractFunctionBodyImpl (AbstractFunctionDecl *AFD) {
6335
+ assert (Tok.is (tok::l_brace));
6336
+
6337
+ // Enter the arguments for the function into a new function-body scope. We
6338
+ // need this even if there is no function body to detect argument name
6339
+ // duplication.
6340
+ if (auto *P = AFD->getImplicitSelfDecl ())
6341
+ addToScope (P);
6342
+ addParametersToScope (AFD->getParameters ());
6343
+
6344
+ // Establish the new context.
6345
+ ParseFunctionBody CC (*this , AFD);
6346
+ setLocalDiscriminatorToParamList (AFD->getParameters ());
6347
+
6348
+ if (Context.Stats )
6349
+ Context.Stats ->getFrontendCounters ().NumFunctionsParsed ++;
6350
+
6351
+ return parseBraceItemList (diag::invalid_diagnostic);
6352
+ }
6353
+
6354
+ // / Parse function body into \p AFD or skip it for delayed parsing.
6332
6355
void Parser::parseAbstractFunctionBody (AbstractFunctionDecl *AFD) {
6333
6356
if (!Tok.is (tok::l_brace)) {
6334
6357
checkForInputIncomplete ();
@@ -6348,21 +6371,7 @@ void Parser::parseAbstractFunctionBody(AbstractFunctionDecl *AFD) {
6348
6371
6349
6372
Scope S (this , ScopeKind::FunctionBody);
6350
6373
6351
- // Enter the arguments for the function into a new function-body scope. We
6352
- // need this even if there is no function body to detect argument name
6353
- // duplication.
6354
- if (auto *P = AFD->getImplicitSelfDecl ())
6355
- addToScope (P);
6356
- addParametersToScope (AFD->getParameters ());
6357
-
6358
- // Establish the new context.
6359
- ParseFunctionBody CC (*this , AFD);
6360
- setLocalDiscriminatorToParamList (AFD->getParameters ());
6361
-
6362
- if (Context.Stats )
6363
- Context.Stats ->getFrontendCounters ().NumFunctionsParsed ++;
6364
-
6365
- ParserResult<BraceStmt> Body = parseBraceItemList (diag::invalid_diagnostic);
6374
+ ParserResult<BraceStmt> Body = parseAbstractFunctionBodyImpl (AFD);
6366
6375
if (!Body.isNull ()) {
6367
6376
BraceStmt * BS = Body.get ();
6368
6377
AFD->setBodyParsed (BS);
@@ -6445,13 +6454,8 @@ BraceStmt *Parser::parseAbstractFunctionBodyDelayed(AbstractFunctionDecl *AFD) {
6445
6454
// Re-enter the lexical scope.
6446
6455
Scope TopLevelScope (this , ScopeKind::TopLevel);
6447
6456
Scope S (this , ScopeKind::FunctionBody);
6448
- if (auto *P = AFD->getImplicitSelfDecl ())
6449
- addToScope (P);
6450
- addParametersToScope (AFD->getParameters ());
6451
- ParseFunctionBody CC (*this , AFD);
6452
- setLocalDiscriminatorToParamList (AFD->getParameters ());
6453
6457
6454
- return parseBraceItemList (diag::func_decl_without_brace ).getPtrOrNull ();
6458
+ return parseAbstractFunctionBodyImpl (AFD ).getPtrOrNull ();
6455
6459
}
6456
6460
6457
6461
// / Parse a 'enum' declaration, returning true (and doing no token
0 commit comments