[clang] [Clang] Extend lifetime of temporaries in mem-default-init for P2718R0 (PR #86960)

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Sat Apr 6 12:23:25 PDT 2024


================
@@ -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)
----------------
efriedma-quic wrote:

What makes temporaries in for-range statements different from other temporaries?  The standard explicitly defines for-range in terms of a regular for-loop; it shouldn't require any special handling unless our AST is somehow deficient.

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


More information about the cfe-commits mailing list