[clang] d2b0b26 - [Coroutines] Pass size parameter for deallocation function when qualified
Chuanqi Xu via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 6 08:22:53 PST 2023
Author: Chuanqi Xu
Date: 2023-02-07T00:22:22+08:00
New Revision: d2b0b26132ce5d3d9022edbf274f01e9de764673
URL: https://github.com/llvm/llvm-project/commit/d2b0b26132ce5d3d9022edbf274f01e9de764673
DIFF: https://github.com/llvm/llvm-project/commit/d2b0b26132ce5d3d9022edbf274f01e9de764673.diff
LOG: [Coroutines] Pass size parameter for deallocation function when qualified
Close https://github.com/llvm/llvm-project/issues/60545.
Previously, we would only pass the size parameter to the deallocation
function if the type is completely the same. But it is good enough to
make them unqualified the smae.
Added:
Modified:
clang/lib/Sema/SemaCoroutine.cpp
clang/test/SemaCXX/coroutine-dealloc.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaCoroutine.cpp b/clang/lib/Sema/SemaCoroutine.cpp
index 79c08adb8fab..9678e30699c8 100644
--- a/clang/lib/Sema/SemaCoroutine.cpp
+++ b/clang/lib/Sema/SemaCoroutine.cpp
@@ -1562,7 +1562,7 @@ bool CoroutineStmtBuilder::makeNewAndDeleteExpr() {
const auto *OpDeleteType =
OpDeleteQualType.getTypePtr()->castAs<FunctionProtoType>();
if (OpDeleteType->getNumParams() > DeleteArgs.size() &&
- S.getASTContext().hasSameType(
+ S.getASTContext().hasSameUnqualifiedType(
OpDeleteType->getParamType(DeleteArgs.size()), FrameSize->getType()))
DeleteArgs.push_back(FrameSize);
@@ -1579,7 +1579,7 @@ bool CoroutineStmtBuilder::makeNewAndDeleteExpr() {
// So we are not forced to pass alignment to the deallocation function.
if (S.getLangOpts().CoroAlignedAllocation &&
OpDeleteType->getNumParams() > DeleteArgs.size() &&
- S.getASTContext().hasSameType(
+ S.getASTContext().hasSameUnqualifiedType(
OpDeleteType->getParamType(DeleteArgs.size()),
FrameAlignment->getType()))
DeleteArgs.push_back(FrameAlignment);
diff --git a/clang/test/SemaCXX/coroutine-dealloc.cpp b/clang/test/SemaCXX/coroutine-dealloc.cpp
index 6eca1e6f42f8..762a14465b29 100644
--- a/clang/test/SemaCXX/coroutine-dealloc.cpp
+++ b/clang/test/SemaCXX/coroutine-dealloc.cpp
@@ -25,3 +25,19 @@ struct task {
task f() {
co_return 43;
}
+
+// From https://github.com/llvm/llvm-project/issues/60545
+struct generator {
+ struct promise_type {
+ generator get_return_object();
+ std::suspend_always initial_suspend();
+ std::suspend_always final_suspend() noexcept;
+ void return_void();
+ [[noreturn]] void unhandled_exception();
+
+ static void* operator new(std::size_t size);
+ static void operator delete(void* ptr, const std::size_t size);
+ };
+};
+
+generator goo() { co_return; }
More information about the cfe-commits
mailing list