diff options
author | yronglin <yronglin777@gmail.com> | 2024-10-11 00:04:02 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-11 00:04:02 +0800 |
commit | 25d9688c43d37c0c918e9b8ab2f67be35b0fb75f (patch) | |
tree | 978d1a0182b74452a948cf2406b3b965bbd56ee8 /clang/lib/Sema/SemaInit.cpp | |
parent | cb5fbd2f60a5a588bfa4668ea8269c3568cbff6e (diff) | |
download | llvm-25d9688c43d37c0c918e9b8ab2f67be35b0fb75f.zip llvm-25d9688c43d37c0c918e9b8ab2f67be35b0fb75f.tar.gz llvm-25d9688c43d37c0c918e9b8ab2f67be35b0fb75f.tar.bz2 |
[Clang] Extend lifetime of temporaries in mem-default-init for P2718R0 (#86960)
Depends on [CWG1815](https://github.com/llvm/llvm-project/pull/108039).
Fixes https://github.com/llvm/llvm-project/issues/85613.
In [[Clang] Implement P2718R0 "Lifetime extension in range-based for
loops"](https://github.com/llvm/llvm-project/pull/76361), we've not
implement the lifetime extensions for the temporaries which in
`CXXDefaultInitExpr`. As the confirmation in
https://github.com/llvm/llvm-project/issues/85613, we should extend
lifetime for that.
To avoid modifying current CodeGen rules, in a lifetime extension
context, the cleanup of `CXXDefaultInitExpr` was ignored.
---------
Signed-off-by: yronglin <yronglin777@gmail.com>
Diffstat (limited to 'clang/lib/Sema/SemaInit.cpp')
-rw-r--r-- | clang/lib/Sema/SemaInit.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index edd1fe4..5d6a586 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -763,6 +763,8 @@ void InitListChecker::FillInEmptyInitForField(unsigned Init, FieldDecl *Field, SemaRef.currentEvaluationContext().DelayedDefaultInitializationContext = SemaRef.parentEvaluationContext() .DelayedDefaultInitializationContext; + SemaRef.currentEvaluationContext().InLifetimeExtendingContext = + SemaRef.parentEvaluationContext().InLifetimeExtendingContext; DIE = SemaRef.BuildCXXDefaultInitExpr(Loc, Field); } if (DIE.isInvalid()) { |