Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 11 additions & 20 deletions clang/lib/Parse/ParseCXXInlineMethods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "clang/Sema/DeclSpec.h"
#include "clang/Sema/EnterExpressionEvaluationContext.h"
#include "clang/Sema/Scope.h"
#include "llvm/ADT/ScopeExit.h"

using namespace clang;

Expand Down Expand Up @@ -624,14 +625,21 @@ void Parser::ParseLexedMethodDef(LexedMethod &LM) {

Actions.ActOnStartOfFunctionDef(getCurScope(), LM.D);

if (Tok.is(tok::kw_try)) {
ParseFunctionTryBlock(LM.D, FnScope);

auto _ = llvm::make_scope_exit([&]() {
while (Tok.isNot(tok::eof))
ConsumeAnyToken();

if (Tok.is(tok::eof) && Tok.getEofData() == LM.D)
ConsumeAnyToken();

if (auto *FD = dyn_cast_or_null<FunctionDecl>(LM.D))
if (isa<CXXMethodDecl>(FD) ||
FD->isInIdentifierNamespace(Decl::IDNS_OrdinaryFriend))
Actions.ActOnFinishInlineFunctionDef(FD);
});

if (Tok.is(tok::kw_try)) {
ParseFunctionTryBlock(LM.D, FnScope);
return;
}
if (Tok.is(tok::colon)) {
Expand All @@ -641,12 +649,6 @@ void Parser::ParseLexedMethodDef(LexedMethod &LM) {
if (!Tok.is(tok::l_brace)) {
FnScope.Exit();
Actions.ActOnFinishFunctionBody(LM.D, nullptr);

while (Tok.isNot(tok::eof))
ConsumeAnyToken();

if (Tok.is(tok::eof) && Tok.getEofData() == LM.D)
ConsumeAnyToken();
return;
}
} else
Expand All @@ -660,17 +662,6 @@ void Parser::ParseLexedMethodDef(LexedMethod &LM) {
"current template being instantiated!");

ParseFunctionStatementBody(LM.D, FnScope);

while (Tok.isNot(tok::eof))
ConsumeAnyToken();

if (Tok.is(tok::eof) && Tok.getEofData() == LM.D)
ConsumeAnyToken();

if (auto *FD = dyn_cast_or_null<FunctionDecl>(LM.D))
if (isa<CXXMethodDecl>(FD) ||
FD->isInIdentifierNamespace(Decl::IDNS_OrdinaryFriend))
Actions.ActOnFinishInlineFunctionDef(FD);
}

/// ParseLexedMemberInitializers - We finished parsing the member specification
Expand Down
13 changes: 13 additions & 0 deletions clang/test/Modules/try-func-body.cppm
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// RUN: %clang_cc1 -std=c++20 %s -fexceptions -fcxx-exceptions -emit-llvm -triple %itanium_abi_triple -o - | FileCheck %s

export module func;
class C {
public:
void member() try {

} catch (...) {

}
};

// CHECK: define {{.*}}@_ZNW4func1C6memberEv
Loading