[llvm-branch-commits] [clang] 867c59c - [Coroutines] Pass size parameter for deallocation function when qualified

Tobias Hieta via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Mar 24 00:45:16 PDT 2023


Author: Chuanqi Xu
Date: 2023-03-24T08:44:33+01:00
New Revision: 867c59c2da1791fcdfd51a750202b3c8c2b4e7ad

URL: https://github.com/llvm/llvm-project/commit/867c59c2da1791fcdfd51a750202b3c8c2b4e7ad
DIFF: https://github.com/llvm/llvm-project/commit/867c59c2da1791fcdfd51a750202b3c8c2b4e7ad.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.

(cherry picked from commit d2b0b26132ce5d3d9022edbf274f01e9de764673)

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 llvm-branch-commits mailing list