1717#include " clang/Sema/DeclSpec.h"
1818#include " clang/Sema/EnterExpressionEvaluationContext.h"
1919#include " clang/Sema/Scope.h"
20+ #include " llvm/ADT/ScopeExit.h"
2021
2122using namespace clang ;
2223
@@ -624,6 +625,13 @@ void Parser::ParseLexedMethodDef(LexedMethod &LM) {
624625
625626 Actions.ActOnStartOfFunctionDef (getCurScope (), LM.D );
626627
628+ auto _ = llvm::make_scope_exit ([&]() {
629+ if (auto *FD = dyn_cast_or_null<FunctionDecl>(LM.D ))
630+ if (isa<CXXMethodDecl>(FD) ||
631+ FD->isInIdentifierNamespace (Decl::IDNS_OrdinaryFriend))
632+ Actions.ActOnFinishInlineFunctionDef (FD);
633+ });
634+
627635 if (Tok.is (tok::kw_try)) {
628636 ParseFunctionTryBlock (LM.D , FnScope);
629637
@@ -632,11 +640,6 @@ void Parser::ParseLexedMethodDef(LexedMethod &LM) {
632640
633641 if (Tok.is (tok::eof) && Tok.getEofData () == LM.D )
634642 ConsumeAnyToken ();
635-
636- if (auto *FD = dyn_cast_or_null<FunctionDecl>(LM.D ))
637- if (isa<CXXMethodDecl>(FD) ||
638- FD->isInIdentifierNamespace (Decl::IDNS_OrdinaryFriend))
639- Actions.ActOnFinishInlineFunctionDef (FD);
640643 return ;
641644 }
642645 if (Tok.is (tok::colon)) {
@@ -671,11 +674,6 @@ void Parser::ParseLexedMethodDef(LexedMethod &LM) {
671674
672675 if (Tok.is (tok::eof) && Tok.getEofData () == LM.D )
673676 ConsumeAnyToken ();
674-
675- if (auto *FD = dyn_cast_or_null<FunctionDecl>(LM.D ))
676- if (isa<CXXMethodDecl>(FD) ||
677- FD->isInIdentifierNamespace (Decl::IDNS_OrdinaryFriend))
678- Actions.ActOnFinishInlineFunctionDef (FD);
679677}
680678
681679// / ParseLexedMemberInitializers - We finished parsing the member specification
0 commit comments