================ @@ -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:
@cor3ntin I tried this code https://godbolt.org/z/n77v9rMTz , and the temporaries which in `CXXDefaultInitExpr` has been lifetime extended in AST. But the LLVM IR unexpected, and the lifetime of the temporaries was not extended. Could you please guide me as to why this is and whether I have made some mistake? https://github.com/llvm/llvm-project/pull/76361 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits