================
@@ -6375,12 +6383,16 @@ ExprResult Sema::BuildCXXDefaultInitExpr(SourceLocation
Loc, FieldDecl *Field) {
ImmediateCallVisitor V(getASTContext());
if (!NestedDefaultChecking)
V.TraverseDecl(Field);
- if (V.HasImmediateCalls) {
+ if (V.HasImmediateCalls || InLifetimeExtendingContext) {
ExprEvalContexts.back().DelayedDefaultInitializationContext = {Loc, Field,
CurContext};
ExprEvalContexts.back().IsCurrentlyCheckingDefaultArgumentOrInitializer =
NestedDefaultChecking;
+ // Pass down lifetime extending flag, and collect temporaries in
+ // CreateMaterializeTemporaryExpr when we rewrite the call argument.
+ keepInLifetimeExtendingContext();
+ keepInMaterializeTemporaryObjectContext();
----------------
yronglin wrote:
Thanks for your help! I have a case use aggregate initialization
(https://godbolt.org/z/vn8Y11ja8). I think neither the brace-or-equals
initializer nor default member initializer should not be materialized and
lifetime-extended in this code snippet, seems they don't satisfy any of
[class.temporary P2](http://eel.is/c++draft/class.temporary#2) .
@hubert-reinterpretcast Could you please give me an example where
`CXXDefaultInitExpr` has to be lifetime-extended? I saw you comment in D153701
that we need to do lifetime-extend for `CXXDefaultInitExpr`. I'm sorry that I'm
unfamiliar with that part of clang and I have no clue how to write tests for
CXXDefaultInitExpr.
https://github.com/llvm/llvm-project/pull/76361
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits