[llvm-branch-commits] [clang] release/19.x: [C++20] [Modules] Treat constexpr/consteval member function as implicitly inline (PR #109076)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Sep 17 19:43:37 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-modules
Author: None (llvmbot)
<details>
<summary>Changes</summary>
Backport 74ac96ae1a81c7ecc0e27ff6f45309cff1f2df97
Requested by: @<!-- -->ChuanqiXu9
---
Full diff: https://github.com/llvm/llvm-project/pull/109076.diff
2 Files Affected:
- (modified) clang/lib/Sema/SemaDecl.cpp (+1)
- (added) clang/test/Modules/pr107673.cppm (+12)
``````````diff
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index d608dd92a4b479..d3c07d0a76f12e 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -9732,6 +9732,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
``````````
</details>
https://github.com/llvm/llvm-project/pull/109076
More information about the llvm-branch-commits
mailing list