Skip to content

Commit b881b16

Browse files
ChuanqiXu9tru
authored andcommitted
[C++20] [Modules] Treat constexpr/consteval member function as implicitly inline
Close llvm#107673 (cherry picked from commit 74ac96a)
1 parent 52a05d3 commit b881b16

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

clang/lib/Sema/SemaDecl.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -9732,6 +9732,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
97329732
// the function decl is created above).
97339733
// FIXME: We need a better way to separate C++ standard and clang modules.
97349734
bool ImplicitInlineCXX20 = !getLangOpts().CPlusPlusModules ||
9735+
NewFD->isConstexpr() || NewFD->isConsteval() ||
97359736
!NewFD->getOwningModule() ||
97369737
NewFD->isFromExplicitGlobalModule() ||
97379738
NewFD->getOwningModule()->isHeaderLikeModule();

clang/test/Modules/pr107673.cppm

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %clang_cc1 -std=c++20 %s -ast-dump | FileCheck %s
2+
export module a;
3+
export class f {
4+
public:
5+
void non_inline_func() {}
6+
constexpr void constexpr_func() {}
7+
consteval void consteval_func() {}
8+
};
9+
10+
// CHECK-NOT: non_inline_func {{.*}}implicit-inline
11+
// CHECK: constexpr_func {{.*}}implicit-inline
12+
// CHECK: consteval_func {{.*}}implicit-inline

0 commit comments

Comments
 (0)