[clang] 74ac96a - [C++20] [Modules] Treat constexpr/consteval member function as implicitly inline
Chuanqi Xu via cfe-commits
cfe-commits at lists.llvm.org
Sun Sep 8 20:25:49 PDT 2024
Author: Chuanqi Xu
Date: 2024-09-09T11:24:50+08:00
New Revision: 74ac96ae1a81c7ecc0e27ff6f45309cff1f2df97
URL: https://github.com/llvm/llvm-project/commit/74ac96ae1a81c7ecc0e27ff6f45309cff1f2df97
DIFF: https://github.com/llvm/llvm-project/commit/74ac96ae1a81c7ecc0e27ff6f45309cff1f2df97.diff
LOG: [C++20] [Modules] Treat constexpr/consteval member function as implicitly inline
Close https://github.com/llvm/llvm-project/issues/107673
Added:
clang/test/Modules/pr107673.cppm
Modified:
clang/lib/Sema/SemaDecl.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 0f63c764536ecb..3c6a0dff798ff6 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -9766,6 +9766,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
// the function decl is created above).
// FIXME: We need a better way to separate C++ standard and clang modules.
bool ImplicitInlineCXX20 = !getLangOpts().CPlusPlusModules ||
+ NewFD->isConstexpr() || NewFD->isConsteval() ||
!NewFD->getOwningModule() ||
NewFD->isFromExplicitGlobalModule() ||
NewFD->getOwningModule()->isHeaderLikeModule();
diff --git a/clang/test/Modules/pr107673.cppm b/clang/test/Modules/pr107673.cppm
new file mode 100644
index 00000000000000..dc66c9ac2245b3
--- /dev/null
+++ b/clang/test/Modules/pr107673.cppm
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -std=c++20 %s -ast-dump | FileCheck %s
+export module a;
+export class f {
+public:
+ void non_inline_func() {}
+ constexpr void constexpr_func() {}
+ consteval void consteval_func() {}
+};
+
+// CHECK-NOT: non_inline_func {{.*}}implicit-inline
+// CHECK: constexpr_func {{.*}}implicit-inline
+// CHECK: consteval_func {{.*}}implicit-inline
More information about the cfe-commits
mailing list