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

Marco Vitale via cfe-commits cfe-commits at lists.llvm.org
Sat Jun 28 01:14:59 PDT 2025


mrcvtl 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?

Agreed.

My last commit should implement this. Let me know if something is wrong! 

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


More information about the cfe-commits mailing list