[clang] [clang] Fix assertion failure when transforming co_yield in invalid coroutine (PR #176082)

Younan Zhang via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 14 21:05:59 PST 2026


================
@@ -8956,6 +8956,15 @@ TreeTransform<Derived>::TransformDependentCoawaitExpr(DependentCoawaitExpr *E) {
 template<typename Derived>
 ExprResult
 TreeTransform<Derived>::TransformCoyieldExpr(CoyieldExpr *E) {
+  // FINAL FIX: Strict check.
+  // 1. If we are in a function scope, but the CoroutinePromise is missing
+  // (null),
+  //    it means the coroutine setup failed (e.g. valid promise type not found).
+  // 2. If the promise exists but is invalid, we also fail.
+  if (clang::sema::FunctionScopeInfo *FSI = getSema().getCurFunction()) {
----------------
zyn0217 wrote:

I think we are not supposed to get here if the surrounding promise is invalid. Can you explore if we can bail out early before TreeTransform?

https://github.com/llvm/llvm-project/pull/176082


More information about the cfe-commits mailing list