[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:55 PST 2024
================
@@ -2288,10 +2288,11 @@ StmtResult Parser::ParseForStatement(SourceLocation *TrailingElseLoc) {
ForRangeStmt = Actions.ActOnCXXForRangeStmt(
getCurScope(), ForLoc, CoawaitLoc, FirstPart.get(),
ForRangeInfo.LoopVar.get(), ForRangeInfo.ColonLoc, CorrectedRange.get(),
- T.getCloseLocation(), Sema::BFRK_Build);
+ T.getCloseLocation(), Sema::BFRK_Build,
+ ForRangeInfo.LifetimeExtendTemps);
- // Similarly, we need to do the semantic analysis for a for-range
- // statement immediately in order to close over temporaries correctly.
+ // Similarly, we need to do the semantic analysis for a for-range
+ // statement immediately in order to close over temporaries correctly.
} else if (ForEach) {
ForEachStmt = Actions.ActOnObjCForCollectionStmt(ForLoc,
----------------
AaronBallman wrote:
```suggestion
} else if (ForEach) {
// Similarly, we need to do the semantic analysis for a for-range
// statement immediately in order to close over temporaries correctly.
ForEachStmt = Actions.ActOnObjCForCollectionStmt(ForLoc,
```
Might as well move the comment to where it belongs.
https://github.com/llvm/llvm-project/pull/76361
More information about the cfe-commits
mailing list