From: Anders Carlsson Date: Fri, 29 Jan 2010 18:30:20 +0000 (+0000) Subject: Get rid of another old PerformCopyInitialization call. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c6acbc58a7aef0a3382775424c80e9534b54b2ed;p=clang Get rid of another old PerformCopyInitialization call. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94819 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index ca15de2cf2..4e3e038144 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -991,11 +991,19 @@ Sema::ActOnBlockReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) { // In C++ the return statement is handled via a copy initialization. // the C version of which boils down to CheckSingleAssignmentConstraints. - // FIXME: Leaks RetValExp. - if (PerformCopyInitialization(RetValExp, FnRetType, AA_Returning)) + OwningExprResult Res = PerformCopyInitialization( + InitializedEntity::InitializeResult(ReturnLoc, + FnRetType), + SourceLocation(), + Owned(RetValExp)); + if (Res.isInvalid()) { + // FIXME: Cleanup temporaries here, anyway? return StmtError(); - - if (RetValExp) CheckReturnStackAddr(RetValExp, FnRetType, ReturnLoc); + } + + RetValExp = Res.takeAs(); + if (RetValExp) + CheckReturnStackAddr(RetValExp, FnRetType, ReturnLoc); } return Owned(new (Context) ReturnStmt(ReturnLoc, RetValExp));