Skip to content

Commit 8876ef7

Browse files
committed
[C++20] [Modules] Support generating in-class defined function with try-catch body
See the example: ``` export module func; class C { public: void member() try { } catch (...) { } }; ``` We woudln't generate the definition for `C::member` but we should. Since the function is non-inline in modules. This turns out to be an oversight in parser to me. Since the try-catch body is relatively rare, so maybe we just forgot it.
1 parent d0edd93 commit 8876ef7

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

clang/lib/Parse/ParseCXXInlineMethods.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,11 @@ void Parser::ParseLexedMethodDef(LexedMethod &LM) {
632632

633633
if (Tok.is(tok::eof) && Tok.getEofData() == LM.D)
634634
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);
635640
return;
636641
}
637642
if (Tok.is(tok::colon)) {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// RUN: %clang_cc1 -std=c++20 %s -fexceptions -fcxx-exceptions -emit-llvm -triple %itanium_abi_triple -o - | FileCheck %s
2+
3+
export module func;
4+
class C {
5+
public:
6+
void member() try {
7+
8+
} catch (...) {
9+
10+
}
11+
};
12+
13+
// CHECK: define {{.*}}@_ZNW4func1C6memberEv

0 commit comments

Comments
 (0)