[clang] [Clang] Implement P2718R0 "Lifetime extension in range-based for loops" (PR #76361)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 11 12:02:29 PST 2024
================
@@ -8244,11 +8229,33 @@ ExprResult Sema::IgnoredValueConversions(Expr *E) {
// If the expression is a prvalue after this optional conversion, the
// temporary materialization conversion is applied.
//
- // We skip this step: IR generation is able to synthesize the storage for
- // itself in the aggregate case, and adding the extra node to the AST is
- // just clutter.
- // FIXME: We don't emit lifetime markers for the temporaries due to this.
- // FIXME: Do any other AST consumers care about this?
+ // We do not materialize temporaries by default in order to avoid creating
+ // unnecessary temporary objects. If we skip this step, IR generation is
+ // able to synthesize the storage for itself in the aggregate case, and
+ // adding the extra node to the AST is just clutter.
+ if (ShouldMaterializePRValueInDiscardedExpression() &&
+ getLangOpts().CPlusPlus17 && E->isPRValue() &&
----------------
AaronBallman wrote:
Ah okay, so this is still related to the lifetime extension for range-based for loops -- we needed this bit for C++17 conformance which we previously didn't have to do?
(Mostly trying to reason about whether this is a separate bug fix that should be landed in a separate patch or whether this is related to the correctness for P2718R0.)
https://github.com/llvm/llvm-project/pull/76361
More information about the cfe-commits
mailing list