[clang] [Clang] Implement P2718R0 "Lifetime extension in range-based for loops" (PR #76361)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 11 05:47:56 PST 2024


================
@@ -2539,6 +2539,12 @@ StmtResult Sema::ActOnCXXForRangeStmt(Scope *S, SourceLocation ForLoc,
     return StmtError();
   }
 
+  if (getLangOpts().CPlusPlus23) {
+    auto Entity = InitializedEntity::InitializeVariable(RangeVar);
----------------
AaronBallman wrote:

Please spell out the type instead of using `auto`. Also, should this be a const ref to avoid a copy?

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


More information about the cfe-commits mailing list