]> granicus.if.org Git - clang/commitdiff
Get rid of another old PerformCopyInitialization call.
authorAnders Carlsson <andersca@mac.com>
Fri, 29 Jan 2010 18:30:20 +0000 (18:30 +0000)
committerAnders Carlsson <andersca@mac.com>
Fri, 29 Jan 2010 18:30:20 +0000 (18:30 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94819 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaStmt.cpp

index ca15de2cf2af53f0693dfac0c866facc59e40131..4e3e038144d73fc8f1c80a85a4fb7706ec00f2ff 100644 (file)
@@ -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<Expr>();
+    if (RetValExp) 
+      CheckReturnStackAddr(RetValExp, FnRetType, ReturnLoc);
   }
 
   return Owned(new (Context) ReturnStmt(ReturnLoc, RetValExp));