https://github.com/usx95 updated https://github.com/llvm/llvm-project/pull/78589
>From 07c6ad92fda63e69489933b5cededf8f03a68ef3 Mon Sep 17 00:00:00 2001 From: Utkarsh Saxena <u...@google.com> Date: Thu, 18 Jan 2024 14:38:22 +0000 Subject: [PATCH 1/5] [coroutine] Create coroutine body in the correct eval context --- clang/lib/Sema/SemaCoroutine.cpp | 4 +++ clang/test/SemaCXX/coroutine-promise-ctor.cpp | 34 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 clang/test/SemaCXX/coroutine-promise-ctor.cpp diff --git a/clang/lib/Sema/SemaCoroutine.cpp b/clang/lib/Sema/SemaCoroutine.cpp index 0e0f8f67dcd73e..4e600fd29ee739 100644 --- a/clang/lib/Sema/SemaCoroutine.cpp +++ b/clang/lib/Sema/SemaCoroutine.cpp @@ -21,6 +21,7 @@ #include "clang/AST/StmtCXX.h" #include "clang/Basic/Builtins.h" #include "clang/Lex/Preprocessor.h" +#include "clang/Sema/EnterExpressionEvaluationContext.h" #include "clang/Sema/Initialization.h" #include "clang/Sema/Overload.h" #include "clang/Sema/ScopeInfo.h" @@ -773,6 +774,9 @@ bool Sema::checkFinalSuspendNoThrow(const Stmt *FinalSuspend) { bool Sema::ActOnCoroutineBodyStart(Scope *SC, SourceLocation KWLoc, StringRef Keyword) { + // Ignore previous expr evaluation contexts. + EnterExpressionEvaluationContext PotentiallyEvaluated( + *this, Sema::ExpressionEvaluationContext::PotentiallyEvaluated); if (!checkCoroutineContext(*this, KWLoc, Keyword)) return false; auto *ScopeInfo = getCurFunction(); diff --git a/clang/test/SemaCXX/coroutine-promise-ctor.cpp b/clang/test/SemaCXX/coroutine-promise-ctor.cpp new file mode 100644 index 00000000000000..c8a976e838241f --- /dev/null +++ b/clang/test/SemaCXX/coroutine-promise-ctor.cpp @@ -0,0 +1,34 @@ +// RUN: %clang_cc1 -std=c++20 -ast-dump %s | FileCheck %s +#include "Inputs/std-coroutine.h" + +// Github issue: https://github.com/llvm/llvm-project/issues/78290 +class Gen { + public: + class promise_type { + public: + template<typename... Args> + explicit promise_type(Args...) {} + // CHECK: CXXConstructorDecl {{.*}} used promise_type 'void ()' {{.*}} + // CHECK-NEXT: TemplateArgument pack + // CHECK-NEXT: CompoundStmt {{.*}} + Gen get_return_object() { return {}; } + + void unhandled_exception() {} + void return_void() {} + std::suspend_always await_transform(Gen gen) { return {}; } + + std::suspend_always initial_suspend() { return {}; } + // CHECK: CXXMethodDecl {{.*}} used initial_suspend {{.*}} + std::suspend_always final_suspend() noexcept { return {}; } + // CHECK: CXXMethodDecl {{.*}} used final_suspend {{.*}} + }; +}; + +Gen CoroutineBody() { + if constexpr (0) { + co_await Gen{}; + } + co_await Gen{}; +} + +int main() { return 0; } \ No newline at end of file >From 4058bfbbfa37ae24d0ca044df58e8c8486440b7b Mon Sep 17 00:00:00 2001 From: Utkarsh Saxena <u...@google.com> Date: Thu, 18 Jan 2024 14:50:52 +0000 Subject: [PATCH 2/5] new line --- clang/test/SemaCXX/coroutine-promise-ctor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/test/SemaCXX/coroutine-promise-ctor.cpp b/clang/test/SemaCXX/coroutine-promise-ctor.cpp index c8a976e838241f..787164c58be234 100644 --- a/clang/test/SemaCXX/coroutine-promise-ctor.cpp +++ b/clang/test/SemaCXX/coroutine-promise-ctor.cpp @@ -31,4 +31,4 @@ Gen CoroutineBody() { co_await Gen{}; } -int main() { return 0; } \ No newline at end of file +int main() { return 0; } >From a6e8916cdee8dad31b36e00f30966706252eabc3 Mon Sep 17 00:00:00 2001 From: Utkarsh Saxena <u...@google.com> Date: Thu, 18 Jan 2024 15:05:24 +0000 Subject: [PATCH 3/5] release notes --- clang/docs/ReleaseNotes.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 0ea6f93a1f5df9..3298d77369c959 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -804,7 +804,9 @@ Bug Fixes in This Version Objective-C++ property accesses to not be converted to a function call to the getter in the placement-args of new-expressions. Fixes (`#65053 <https://github.com/llvm/llvm-project/issues/65053>`_) - +- Fix an issue with missing symbol definitions when the first coroutine + statement is part of an disabled branch of ``if constexpr``. + Fixes (`#78290 <https://github.com/llvm/llvm-project/issues/78290>`_) Bug Fixes to Compiler Builtins ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >From c3217aa14861a60d23282d7443132c2d222810ca Mon Sep 17 00:00:00 2001 From: Utkarsh Saxena <u...@google.com> Date: Thu, 18 Jan 2024 15:06:00 +0000 Subject: [PATCH 4/5] new line --- clang/docs/ReleaseNotes.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 3298d77369c959..00df2d3f097490 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -807,6 +807,7 @@ Bug Fixes in This Version - Fix an issue with missing symbol definitions when the first coroutine statement is part of an disabled branch of ``if constexpr``. Fixes (`#78290 <https://github.com/llvm/llvm-project/issues/78290>`_) + Bug Fixes to Compiler Builtins ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >From 6174e6bb4043241a3ad8cee6b5a3a0b3267aa949 Mon Sep 17 00:00:00 2001 From: Utkarsh Saxena <u...@google.com> Date: Thu, 18 Jan 2024 16:12:13 +0100 Subject: [PATCH 5/5] Update clang/docs/ReleaseNotes.rst Co-authored-by: cor3ntin <corentinja...@gmail.com> --- clang/docs/ReleaseNotes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 00df2d3f097490..ec2e9870bc49be 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -805,7 +805,7 @@ Bug Fixes in This Version to the getter in the placement-args of new-expressions. Fixes (`#65053 <https://github.com/llvm/llvm-project/issues/65053>`_) - Fix an issue with missing symbol definitions when the first coroutine - statement is part of an disabled branch of ``if constexpr``. + statement appears in a discarded ``if constexpr`` branch. Fixes (`#78290 <https://github.com/llvm/llvm-project/issues/78290>`_) Bug Fixes to Compiler Builtins _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits