Skip to content

Commit 867c59c

Browse files
ChuanqiXu9tru
authored andcommitted
[Coroutines] Pass size parameter for deallocation function when qualified
Close #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 d2b0b26)
1 parent 6dc69d0 commit 867c59c

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

clang/lib/Sema/SemaCoroutine.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1562,7 +1562,7 @@ bool CoroutineStmtBuilder::makeNewAndDeleteExpr() {
15621562
const auto *OpDeleteType =
15631563
OpDeleteQualType.getTypePtr()->castAs<FunctionProtoType>();
15641564
if (OpDeleteType->getNumParams() > DeleteArgs.size() &&
1565-
S.getASTContext().hasSameType(
1565+
S.getASTContext().hasSameUnqualifiedType(
15661566
OpDeleteType->getParamType(DeleteArgs.size()), FrameSize->getType()))
15671567
DeleteArgs.push_back(FrameSize);
15681568

@@ -1579,7 +1579,7 @@ bool CoroutineStmtBuilder::makeNewAndDeleteExpr() {
15791579
// So we are not forced to pass alignment to the deallocation function.
15801580
if (S.getLangOpts().CoroAlignedAllocation &&
15811581
OpDeleteType->getNumParams() > DeleteArgs.size() &&
1582-
S.getASTContext().hasSameType(
1582+
S.getASTContext().hasSameUnqualifiedType(
15831583
OpDeleteType->getParamType(DeleteArgs.size()),
15841584
FrameAlignment->getType()))
15851585
DeleteArgs.push_back(FrameAlignment);

clang/test/SemaCXX/coroutine-dealloc.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,19 @@ struct task {
2525
task f() {
2626
co_return 43;
2727
}
28+
29+
// From https://github.com/llvm/llvm-project/issues/60545
30+
struct generator {
31+
struct promise_type {
32+
generator get_return_object();
33+
std::suspend_always initial_suspend();
34+
std::suspend_always final_suspend() noexcept;
35+
void return_void();
36+
[[noreturn]] void unhandled_exception();
37+
38+
static void* operator new(std::size_t size);
39+
static void operator delete(void* ptr, const std::size_t size);
40+
};
41+
};
42+
43+
generator goo() { co_return; }

0 commit comments

Comments
 (0)