[clang] [clang] In Sema use new parentEvaluationContext function (PR #93338)
Oleksandr T. via cfe-commits
cfe-commits at lists.llvm.org
Fri May 24 16:44:26 PDT 2024
================
@@ -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
More information about the cfe-commits
mailing list