================
@@ -1230,11 +1230,26 @@ CodeGenFunction::EmitCXXForRangeStmt(const
CXXForRangeStmt &S,
JumpDest LoopExit = getJumpDestInCurrentScope("for.end");
LexicalScope ForScope(*this, S.getSourceRange());
+ const DeclStmt *RangeDS = cast<DeclStmt>(S.getRangeStmt());
+ const VarDecl *RangeVar = cast<VarDecl>(RangeDS->getSingleDecl());
+ if (getLangOpts().CPlusPlus23)
----------------
yronglin wrote:
Thanks for your review! [P2718R0](https://wg21.link/P2718R0) introduce lifetime
extensions in for-range loops. Basic support for P2718R0 has been implemented
in https://github.com/llvm/llvm-project/pull/76361 and everything works fine.
When I works on this PR, I found that the lifetime of temporaries
in`CXXDefaultInitExpr` was not extended, even if `MaterializedTemporaryExpr`
sets ExtendingDecl and bound to `__range` variable. So I thought about my
current approach and I'm not sure if this is the correct approach. Can you
provide a direction for improvement? Should we modify the AST instead of
handling it in CodeGen?
https://github.com/llvm/llvm-project/pull/86960
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits