================
@@ -17693,12 +17691,13 @@ void Sema::PopExpressionEvaluationContext() {
 
   // Append the collected materialized temporaries into previous context before
   // exit if the previous also is a lifetime extending context.
-  auto &PrevRecord = ExprEvalContexts[ExprEvalContexts.size() - 2];
+  auto &PrevRecord = parentEvaluationContext();
   if (getLangOpts().CPlusPlus23 && Rec.InLifetimeExtendingContext &&
       PrevRecord.InLifetimeExtendingContext &&
       !Rec.ForRangeLifetimeExtendTemps.empty()) {
-    PrevRecord.ForRangeLifetimeExtendTemps.append(
-        Rec.ForRangeLifetimeExtendTemps);
+    const_cast<SmallVector<MaterializeTemporaryExpr *, 8> &>(
----------------
a-tarasyuk wrote:

I'm uncertain about using `const_cast` in this case. While `EvaluationContext` 
contains properties that can be changed, `parentEvaluationContext` is declared 
as `const`. Maybe `const` shouldn't be used in this case, or we could create a 
new helper to return `ForRangeLifetimeExtendTemps` for parent eval context, or 
avoid applying `parentEvaluationContext` in this case. What do you think 
@Endilll, @Fznamznon?

https://github.com/llvm/llvm-project/pull/93338
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to