[clang] [C++20][Coroutines] Lambda-coroutine with operator new in promise_type (PR #84193)

2024-04-02 Thread Andreas Fertig via cfe-commits
andreasfertig wrote: Hello @ChuanqiXu9, > Hi Andreas, thanks for looking into this. I am still confused about whether > or not your new branch can fix the crash or not. It's my pleasure! The new branch doesn't fix the crash. If I understand why it is crashing, this branch is a better change c

[clang] [C++20][Coroutines] Lambda-coroutine with operator new in promise_type (PR #84193)

2024-04-02 Thread Andreas Fertig via cfe-commits
andreasfertig wrote: Hello all, I did more investigation and found another shortcoming. In some cases, my initial implementation picked the wrong `this`- type, for example, https://github.com/andreasfertig/llvm-project/blob/9c60fec6881cca7e7fed9dca5cf24a0bd1924eaa/clang/test/SemaCXX/coroutine-

[clang] [C++20][Coroutines] lambda-coroutine with promise_type ctor. (PR #84519)

2024-03-11 Thread Andreas Fertig via cfe-commits
https://github.com/andreasfertig converted_to_draft https://github.com/llvm/llvm-project/pull/84519 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [C++20][Coroutines] lambda-coroutine with promise_type ctor. (PR #84519)

2024-03-11 Thread Andreas Fertig via cfe-commits
https://github.com/andreasfertig updated https://github.com/llvm/llvm-project/pull/84519 >From cdeb381fb177a3d2991bdec8495cc952a5453712 Mon Sep 17 00:00:00 2001 From: Andreas Fertig Date: Fri, 8 Mar 2024 17:49:15 +0100 Subject: [PATCH 1/2] [C++20][Coroutines] lambda-coroutine with promise_type

[clang] [C++20][Coroutines] Lambda-coroutine with operator new in promise_type (PR #84193)

2024-03-11 Thread Andreas Fertig via cfe-commits
andreasfertig wrote: Interesting! I'll see what I can do. https://github.com/llvm/llvm-project/pull/84193 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [C++20][Coroutines] lambda-coroutine with promise_type ctor. (PR #84519)

2024-03-10 Thread Andreas Fertig via cfe-commits
andreasfertig wrote: > Can we add a changelog entry for that? Done! https://github.com/llvm/llvm-project/pull/84519 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [C++20][Coroutines] lambda-coroutine with promise_type ctor. (PR #84519)

2024-03-10 Thread Andreas Fertig via cfe-commits
https://github.com/andreasfertig updated https://github.com/llvm/llvm-project/pull/84519 >From cdeb381fb177a3d2991bdec8495cc952a5453712 Mon Sep 17 00:00:00 2001 From: Andreas Fertig Date: Fri, 8 Mar 2024 17:49:15 +0100 Subject: [PATCH] [C++20][Coroutines] lambda-coroutine with promise_type ctor

[clang] [C++20][Coroutines] lambda-coroutine with promise_type ctor. (PR #84519)

2024-03-10 Thread Andreas Fertig via cfe-commits
@@ -596,8 +596,21 @@ VarDecl *Sema::buildCoroutinePromise(SourceLocation Loc) { // Add implicit object parameter. if (auto *MD = dyn_cast(FD)) { -if (MD->isImplicitObjectMemberFunction() && !isLambdaCallOperator(MD)) { - ExprResult ThisExpr = ActOnCXXThis(Loc); +

[clang] [C++20][Coroutines] lambda-coroutine with promise_type ctor. (PR #84519)

2024-03-08 Thread Andreas Fertig via cfe-commits
https://github.com/andreasfertig updated https://github.com/llvm/llvm-project/pull/84519 >From 3083833f9e87947c7e45c5ed5bd6a983294717c9 Mon Sep 17 00:00:00 2001 From: Andreas Fertig Date: Fri, 8 Mar 2024 17:49:15 +0100 Subject: [PATCH] [C++20][Coroutines] lambda-coroutine with promise_type ctor

[clang] [C++20][Coroutines] lambda-coroutine with promise_type ctor. (PR #84519)

2024-03-08 Thread Andreas Fertig via cfe-commits
andreasfertig wrote: @ChuanqiXu9 here is a dedicated patch to support a `promise_type` with a user-provided constructor in a coroutine used with a lambda. https://github.com/llvm/llvm-project/pull/84519 ___ cfe-commits mailing list cfe-commits@lists.l

[clang] [C++20][Coroutines] lambda-coroutine with promise_type ctor. (PR #84519)

2024-03-08 Thread Andreas Fertig via cfe-commits
https://github.com/andreasfertig created https://github.com/llvm/llvm-project/pull/84519 This is a follow-up of #84064. It turned out that a coroutine-lambda with a `promise_type` and a user-defined constructor ignores the `this` pointer. Per http://eel.is/c++draft/dcl.fct.def.coroutine#4, in

[clang] [C++20][Coroutines] Lambda-coroutine with operator new in promise_type (PR #84193)

2024-03-08 Thread Andreas Fertig via cfe-commits
andreasfertig wrote: > @andreasfertig Will you need us to merge that for you? @cor3ntin: It looks like I need you, yes. I can only close the PR :-/ https://github.com/llvm/llvm-project/pull/84193 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang] [C++20][Coroutines] Lambda-coroutine with operator new in promise_type (PR #84193)

2024-03-08 Thread Andreas Fertig via cfe-commits
andreasfertig wrote: The clang-format check fails due to a change in `clang/docs/ReleaseNotes. rst`, which isn't mine. What's the protocol? Shall I fix the format issue, or can my change be merged anyway? https://github.com/llvm/llvm-project/pull/84193 _

[clang] [C++20][Coroutines] Lambda-coroutine with operator new in promise_type (PR #84193)

2024-03-08 Thread Andreas Fertig via cfe-commits
https://github.com/andreasfertig updated https://github.com/llvm/llvm-project/pull/84193 >From 9f8a741864b01e89ea17b5ea4c4296da27ef Mon Sep 17 00:00:00 2001 From: Andreas Fertig Date: Wed, 6 Mar 2024 14:20:00 +0100 Subject: [PATCH] [C++20][Coroutines] Lambda-coroutine with operator new in

[clang] [C++20][Coroutines] Lambda-coroutine with operator new in promise_type (PR #84193)

2024-03-08 Thread Andreas Fertig via cfe-commits
@@ -1434,13 +1434,18 @@ ExprResult Sema::ActOnCXXThis(SourceLocation Loc) { return Diag(Loc, diag::err_invalid_this_use) << 0; } - return BuildCXXThisExpr(Loc, ThisTy, /*IsImplicit=*/false); + return BuildCXXThisExpr(Loc, ThisTy, /*IsImplicit=*/false, +

[clang] [C++20][Coroutines] Lambda-coroutine with operator new in promise_type (PR #84193)

2024-03-08 Thread Andreas Fertig via cfe-commits
@@ -0,0 +1,54 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -I%S/Inputs -std=c++20 %s + +// expected-no-diagnostics + +#include "std-coroutine.h" + +using size_t = decltype(sizeof(0)); + +struct Generator { + struct promise_type { +int _val{}; + +Generator get_return_objec

[clang] [C++20][Coroutines] Lambda-coroutine with operator new in promise_type (PR #84193)

2024-03-08 Thread Andreas Fertig via cfe-commits
@@ -1378,8 +1379,21 @@ bool CoroutineStmtBuilder::makeReturnOnAllocFailure() { static bool collectPlacementArgs(Sema &S, FunctionDecl &FD, SourceLocation Loc, SmallVectorImpl &PlacementArgs) { if (auto *MD = dyn_cast(&FD)) { -if (MD->isImp

[clang] [C++20][Coroutines] Lambda-coroutine with operator new in promise_type (PR #84193)

2024-03-08 Thread Andreas Fertig via cfe-commits
https://github.com/andreasfertig updated https://github.com/llvm/llvm-project/pull/84193 >From 680c99b2d832a5fad617f632df4a750f9c6f1cae Mon Sep 17 00:00:00 2001 From: Andreas Fertig Date: Wed, 6 Mar 2024 14:20:00 +0100 Subject: [PATCH] [C++20][Coroutines] Lambda-coroutine with operator new in

[clang] [C++20][Coroutines] Lambda-coroutine with operator new in promise_type (PR #84193)

2024-03-08 Thread Andreas Fertig via cfe-commits
https://github.com/andreasfertig edited https://github.com/llvm/llvm-project/pull/84193 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [C++20][Coroutines] Lambda-coroutine with operator new in promise_type (PR #84193)

2024-03-08 Thread Andreas Fertig via cfe-commits
@@ -6898,10 +6898,18 @@ class Sema final { BinaryOperatorKind Operator); ActOnCXXThis - Parse 'this' pointer. - ExprResult ActOnCXXThis(SourceLocation loc); + /// + /// \param SkipLambdaCaptureCheck Whether to skip the 'this' check

[clang] [C++20][Coroutines] Lambda-coroutine with operator new in promise_type (PR #84193)

2024-03-06 Thread Andreas Fertig via cfe-commits
@@ -1434,13 +1434,18 @@ ExprResult Sema::ActOnCXXThis(SourceLocation Loc) { return Diag(Loc, diag::err_invalid_this_use) << 0; } - return BuildCXXThisExpr(Loc, ThisTy, /*IsImplicit=*/false); + return BuildCXXThisExpr(Loc, ThisTy, /*IsImplicit=*/false, +

[clang] [C++20][Coroutines] Lambda-coroutine with operator new in promise_type (PR #84193)

2024-03-06 Thread Andreas Fertig via cfe-commits
@@ -0,0 +1,54 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -I%S/Inputs -std=c++20 %s + +// expected-no-diagnostics + +#include "std-coroutine.h" + +using size_t = decltype(sizeof(0)); + +struct Generator { + struct promise_type { +int _val{}; + +Generator get_return_objec

[clang] [C++20][Coroutines] Lambda-coroutine with operator new in promise_type (PR #84193)

2024-03-06 Thread Andreas Fertig via cfe-commits
@@ -6898,10 +6898,18 @@ class Sema final { BinaryOperatorKind Operator); ActOnCXXThis - Parse 'this' pointer. - ExprResult ActOnCXXThis(SourceLocation loc); + /// + /// \param SkipLambdaCaptureCheck Whether to skip the 'this' check

[clang] [C++20][Coroutines] Lambda-coroutine with operator new in promise_type (PR #84193)

2024-03-06 Thread Andreas Fertig via cfe-commits
https://github.com/andreasfertig edited https://github.com/llvm/llvm-project/pull/84193 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [C++20][Coroutines] Lambda-coroutine with operator new in promise_type (PR #84193)

2024-03-06 Thread Andreas Fertig via cfe-commits
https://github.com/andreasfertig edited https://github.com/llvm/llvm-project/pull/84193 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [C++20][Coroutines] Lambda-coroutine with operator new in promise_type (PR #84193)

2024-03-06 Thread Andreas Fertig via cfe-commits
@@ -6898,10 +6898,18 @@ class Sema final { BinaryOperatorKind Operator); ActOnCXXThis - Parse 'this' pointer. - ExprResult ActOnCXXThis(SourceLocation loc); + /// + /// \param SkipLambdaCaptureCheck Whether to skip the 'this' check

[clang] [C++20][Coroutines] Lambda-coroutine with operator new in promise_type (PR #84193)

2024-03-06 Thread Andreas Fertig via cfe-commits
@@ -6898,10 +6898,18 @@ class Sema final { BinaryOperatorKind Operator); ActOnCXXThis - Parse 'this' pointer. - ExprResult ActOnCXXThis(SourceLocation loc); + /// + /// \param SkipLambdaCaptureCheck Whether to skip the 'this' check

[clang] [C++20][Coroutines] Lambda-coroutine with operator new in promise_type (PR #84193)

2024-03-06 Thread Andreas Fertig via cfe-commits
https://github.com/andreasfertig created https://github.com/llvm/llvm-project/pull/84193 Fix #84064 According to http://eel.is/c++draft/dcl.fct.def.coroutine#9 the first parameter for overload resolution of `operator new` is `size_t` followed by the arguments of the coroutine function. http:/