[clang] [Sema] Fix lifetime extension for temporaries in range-based for loops in C++23 (PR #145164)

via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 27 08:32:19 PDT 2025


yronglin wrote:

> but why can’t we use InLifetimeExtendingContext flag here? 
> Is there a subtle difference I’m missing?

This flag will tiger subroutines to collect `MaterializedTemporaryExpr` and rebuild default init/arg。 All we need to know here is that `ExtendingDecl` is a C++ `__range` var in for-range-loop, so I think we should introduce a new flag in VarDecl. We may need to also modify handling of VarDecl in ASTWriter and ASTReader to ensure that the AST serialization is correct. WDYT?

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


More information about the cfe-commits mailing list