[clang] [Clang] Implement P2718R0 "Lifetime extension in range-based for loops" (PR #76361)

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 17 12:18:46 PST 2024


================
@@ -1357,6 +1363,19 @@ class Sema final {
     // VLAs).
     bool InConditionallyConstantEvaluateContext = false;
 
+    /// Whether we are currently in a context in which temporaries must be
+    /// lifetime-extended (Eg. in a for-range initializer).
+    bool IsInLifetimeExtendingContext = false;
----------------
zygoloid wrote:

I think we should be clear here that this is only for unusual lifetime-extension contexts, and not just (for example) in an initializer of a reference.
```suggestion
    /// Whether we are currently in a context in which all temporaries must be
    /// lifetime-extended, even if they're not bound to a reference (for example,
    /// in a for-range initializer).
    bool IsInLifetimeExtendingContext = false;
```

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


More information about the cfe-commits mailing list