Convert some more statement actions to smart pointers.
Fix a type error; parser wanted to pass the third part of a for-statement as a statement; should be expression.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62380 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp
index 153aeb8..1bc7858 100644
--- a/lib/Parse/ParseStmt.cpp
+++ b/lib/Parse/ParseStmt.cpp
@@ -722,7 +722,8 @@
if (Cond.isInvalid() || Body.isInvalid())
return StmtError();
- return Owned(Actions.ActOnWhileStmt(WhileLoc, Cond.release(),Body.release()));
+ return Actions.ActOnWhileStmt(WhileLoc, move_convert(Cond),
+ move_convert(Body));
}
/// ParseDoStatement
@@ -786,8 +787,8 @@
if (Cond.isInvalid() || Body.isInvalid())
return StmtError();
- return Owned(Actions.ActOnDoStmt(DoLoc, Body.release(), WhileLoc,
- Cond.release()));
+ return Actions.ActOnDoStmt(DoLoc, move_convert(Body), WhileLoc,
+ move_convert(Cond));
}
/// ParseForStatement
@@ -843,8 +844,8 @@
OwningExprResult Value(Actions);
bool ForEach = false;
- OwningStmtResult FirstPart(Actions), ThirdPart(Actions);
- OwningExprResult SecondPart(Actions);
+ OwningStmtResult FirstPart(Actions);
+ OwningExprResult SecondPart(Actions), ThirdPart(Actions);
// Parse the first part of the for specifier.
if (Tok.is(tok::semi)) { // for (;
@@ -903,11 +904,7 @@
if (Tok.is(tok::r_paren)) { // for (...;...;)
// no third part.
} else {
- Value = ParseExpression();
- if (!Value.isInvalid()) {
- // Turn the expression into a stmt.
- ThirdPart = Actions.ActOnExprStmt(move_convert(Value));
- }
+ ThirdPart = ParseExpression();
}
}
// Match the ')'.
@@ -940,14 +937,14 @@
return StmtError();
if (!ForEach)
- return Owned(Actions.ActOnForStmt(ForLoc, LParenLoc, FirstPart.release(),
- SecondPart.release(), ThirdPart.release(),
- RParenLoc, Body.release()));
+ return Actions.ActOnForStmt(ForLoc, LParenLoc, move_convert(FirstPart),
+ move_convert(SecondPart), move_convert(ThirdPart),
+ RParenLoc, move_convert(Body));
else
- return Owned(Actions.ActOnObjCForCollectionStmt(ForLoc, LParenLoc,
- FirstPart.release(),
- SecondPart.release(),
- RParenLoc, Body.release()));
+ return Actions.ActOnObjCForCollectionStmt(ForLoc, LParenLoc,
+ move_convert(FirstPart),
+ move_convert(SecondPart),
+ RParenLoc, move_convert(Body));
}
/// ParseGotoStatement