Change ActOnReturnStmt to not take a FullExprArg. Instead, Sema will wrap the return expr inside a CXXExprWithTemporaries if needed.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79342 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h
index d3bdec8..9230531 100644
--- a/lib/Sema/Sema.h
+++ b/lib/Sema/Sema.h
@@ -1366,7 +1366,7 @@
Scope *CurScope);
virtual OwningStmtResult ActOnReturnStmt(SourceLocation ReturnLoc,
- FullExprArg RetValExp);
+ ExprArg RetValExp);
OwningStmtResult ActOnBlockReturnStmt(SourceLocation ReturnLoc,
Expr *RetValExp);
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp
index 5794338..d1bb0df 100644
--- a/lib/Sema/SemaStmt.cpp
+++ b/lib/Sema/SemaStmt.cpp
@@ -867,8 +867,8 @@
}
Action::OwningStmtResult
-Sema::ActOnReturnStmt(SourceLocation ReturnLoc, FullExprArg rex) {
- Expr *RetValExp = rex->takeAs<Expr>();
+Sema::ActOnReturnStmt(SourceLocation ReturnLoc, ExprArg rex) {
+ Expr *RetValExp = rex.takeAs<Expr>();
if (CurBlock)
return ActOnBlockReturnStmt(ReturnLoc, RetValExp);
@@ -897,6 +897,8 @@
<< CurDecl->getDeclName() << isa<ObjCMethodDecl>(CurDecl)
<< RetValExp->getSourceRange();
}
+
+ RetValExp = MaybeCreateCXXExprWithTemporaries(RetValExp, true);
}
return Owned(new (Context) ReturnStmt(ReturnLoc, RetValExp));
}
@@ -945,6 +947,8 @@
if (RetValExp) CheckReturnStackAddr(RetValExp, FnRetType, ReturnLoc);
}
+ if (RetValExp)
+ RetValExp = MaybeCreateCXXExprWithTemporaries(RetValExp, true);
return Owned(new (Context) ReturnStmt(ReturnLoc, RetValExp));
}
diff --git a/lib/Sema/SemaTemplateInstantiateStmt.cpp b/lib/Sema/SemaTemplateInstantiateStmt.cpp
index 80ff5eb..b42b84d 100644
--- a/lib/Sema/SemaTemplateInstantiateStmt.cpp
+++ b/lib/Sema/SemaTemplateInstantiateStmt.cpp
@@ -130,7 +130,7 @@
return SemaRef.StmtError();
}
- return SemaRef.ActOnReturnStmt(S->getReturnLoc(), FullExpr(Result));
+ return SemaRef.ActOnReturnStmt(S->getReturnLoc(), move(Result));
}
Sema::OwningStmtResult