[clang] Reapply "[Clang][CWG1815] Support lifetime extension of temporary created by aggregate initialization using a default member initializer" (PR #108039)

via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 11 07:27:19 PDT 2024


================
@@ -7810,9 +7813,11 @@ class Sema final : public SemaBase {
   }
 
   bool isInLifetimeExtendingContext() const {
-    assert(!ExprEvalContexts.empty() &&
----------------
yronglin wrote:

We check `isInLifetimeExtendingContext` when we create a `MaterializedTemporaryExpr`, if in a lifetime extend context, we will collect created MaterializedTemporaryExprs and extend its lifetime to a variable. 
e.g. (P2718R0 - Lifetime extension in range-based for loops.)In a for-range statement, we collect temporaries in for-range-init, and extend it's lifetime bound to for-range-var.

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


More information about the cfe-commits mailing list