return StmtEmpty();
}
- virtual StmtResult ActOnWhileStmt(SourceLocation WhileLoc, ExprTy *Cond,
- StmtTy *Body) {
+ virtual OwningStmtResult ActOnWhileStmt(SourceLocation WhileLoc,
+ ExprArg Cond, StmtArg Body) {
llvm::cout << __FUNCTION__ << "\n";
- return 0;
+ return StmtEmpty();
}
- virtual StmtResult ActOnDoStmt(SourceLocation DoLoc, StmtTy *Body,
- SourceLocation WhileLoc, ExprTy *Cond) {
+ virtual OwningStmtResult ActOnDoStmt(SourceLocation DoLoc, StmtArg Body,
+ SourceLocation WhileLoc, ExprArg Cond){
llvm::cout << __FUNCTION__ << "\n";
- return 0;
+ return StmtEmpty();
}
- virtual StmtResult ActOnForStmt(SourceLocation ForLoc,
- SourceLocation LParenLoc,
- StmtTy *First, ExprTy *Second, ExprTy *Third,
- SourceLocation RParenLoc, StmtTy *Body) {
+ virtual OwningStmtResult ActOnForStmt(SourceLocation ForLoc,
+ SourceLocation LParenLoc,
+ StmtArg First, ExprArg Second,
+ ExprArg Third, SourceLocation RParenLoc,
+ StmtArg Body) {
llvm::cout << __FUNCTION__ << "\n";
- return 0;
+ return StmtEmpty();
}
- virtual StmtResult ActOnObjCForCollectionStmt(SourceLocation ForColLoc,
- SourceLocation LParenLoc,
- StmtTy *First, ExprTy *Second,
- SourceLocation RParenLoc, StmtTy *Body) {
+ virtual OwningStmtResult ActOnObjCForCollectionStmt(
+ SourceLocation ForColLoc,
+ SourceLocation LParenLoc,
+ StmtArg First, ExprArg Second,
+ SourceLocation RParenLoc, StmtArg Body) {
llvm::cout << __FUNCTION__ << "\n";
- return 0;
+ return StmtEmpty();
}
virtual StmtResult ActOnGotoStmt(SourceLocation GotoLoc,
SourceLocation LabelLoc,
return StmtEmpty();
}
- virtual StmtResult ActOnWhileStmt(SourceLocation WhileLoc, ExprTy *Cond,
- StmtTy *Body) {
- return 0;
+ virtual OwningStmtResult ActOnWhileStmt(SourceLocation WhileLoc, ExprArg Cond,
+ StmtArg Body) {
+ return StmtEmpty();
}
- virtual StmtResult ActOnDoStmt(SourceLocation DoLoc, StmtTy *Body,
- SourceLocation WhileLoc, ExprTy *Cond) {
- return 0;
+ virtual OwningStmtResult ActOnDoStmt(SourceLocation DoLoc, StmtArg Body,
+ SourceLocation WhileLoc, ExprArg Cond) {
+ return StmtEmpty();
}
- virtual StmtResult ActOnForStmt(SourceLocation ForLoc,
- SourceLocation LParenLoc,
- StmtTy *First, ExprTy *Second, ExprTy *Third,
- SourceLocation RParenLoc, StmtTy *Body) {
- return 0;
+ virtual OwningStmtResult ActOnForStmt(SourceLocation ForLoc,
+ SourceLocation LParenLoc,
+ StmtArg First, ExprArg Second,
+ ExprArg Third, SourceLocation RParenLoc,
+ StmtArg Body) {
+ return StmtEmpty();
}
- virtual StmtResult ActOnObjCForCollectionStmt(SourceLocation ForColLoc,
- SourceLocation LParenLoc,
- StmtTy *First, ExprTy *Second,
- SourceLocation RParenLoc, StmtTy *Body) {
- return 0;
+ virtual OwningStmtResult ActOnObjCForCollectionStmt(SourceLocation ForColLoc,
+ SourceLocation LParenLoc,
+ StmtArg First, ExprArg Second,
+ SourceLocation RParenLoc, StmtArg Body) {
+ return StmtEmpty();
}
virtual StmtResult ActOnGotoStmt(SourceLocation GotoLoc,
SourceLocation LabelLoc,
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
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
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 (;
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 ')'.
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
virtual OwningStmtResult ActOnStartOfSwitchStmt(ExprArg Cond);
virtual OwningStmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc,
StmtArg Switch, StmtArg Body);
- virtual StmtResult ActOnWhileStmt(SourceLocation WhileLoc, ExprTy *Cond,
- StmtTy *Body);
- virtual StmtResult ActOnDoStmt(SourceLocation DoLoc, StmtTy *Body,
- SourceLocation WhileLoc, ExprTy *Cond);
-
- virtual StmtResult ActOnForStmt(SourceLocation ForLoc,
- SourceLocation LParenLoc,
- StmtTy *First, ExprTy *Second, ExprTy *Third,
- SourceLocation RParenLoc, StmtTy *Body);
- virtual StmtResult ActOnObjCForCollectionStmt(SourceLocation ForColLoc,
- SourceLocation LParenLoc,
- StmtTy *First, ExprTy *Second,
- SourceLocation RParenLoc, StmtTy *Body);
+ virtual OwningStmtResult ActOnWhileStmt(SourceLocation WhileLoc, ExprArg Cond,
+ StmtArg Body);
+ virtual OwningStmtResult ActOnDoStmt(SourceLocation DoLoc, StmtArg Body,
+ SourceLocation WhileLoc, ExprArg Cond);
+
+ virtual OwningStmtResult ActOnForStmt(SourceLocation ForLoc,
+ SourceLocation LParenLoc,
+ StmtArg First, ExprArg Second,
+ ExprArg Third, SourceLocation RParenLoc,
+ StmtArg Body);
+ virtual OwningStmtResult ActOnObjCForCollectionStmt(SourceLocation ForColLoc,
+ SourceLocation LParenLoc,
+ StmtArg First, ExprArg Second,
+ SourceLocation RParenLoc, StmtArg Body);
virtual StmtResult ActOnGotoStmt(SourceLocation GotoLoc,
SourceLocation LabelLoc,
return Owned(SS);
}
-Action::StmtResult
-Sema::ActOnWhileStmt(SourceLocation WhileLoc, ExprTy *Cond, StmtTy *Body) {
- Expr *condExpr = (Expr *)Cond;
+Action::OwningStmtResult
+Sema::ActOnWhileStmt(SourceLocation WhileLoc, ExprArg Cond, StmtArg Body) {
+ Expr *condExpr = (Expr *)Cond.release();
assert(condExpr && "ActOnWhileStmt(): missing expression");
-
+
DefaultFunctionArrayConversion(condExpr);
+ Cond = condExpr;
QualType condType = condExpr->getType();
-
+
if (getLangOptions().CPlusPlus) {
if (CheckCXXBooleanCondition(condExpr)) // C++ 6.4p4
- return true;
+ return StmtError();
} else if (!condType->isScalarType()) // C99 6.8.5p2
- return Diag(WhileLoc, diag::err_typecheck_statement_requires_scalar)
- << condType << condExpr->getSourceRange();
+ return StmtError(Diag(WhileLoc,
+ diag::err_typecheck_statement_requires_scalar)
+ << condType << condExpr->getSourceRange());
- return new WhileStmt(condExpr, (Stmt*)Body, WhileLoc);
+ Cond.release();
+ return Owned(new WhileStmt(condExpr, (Stmt*)Body.release(), WhileLoc));
}
-Action::StmtResult
-Sema::ActOnDoStmt(SourceLocation DoLoc, StmtTy *Body,
- SourceLocation WhileLoc, ExprTy *Cond) {
- Expr *condExpr = (Expr *)Cond;
+Action::OwningStmtResult
+Sema::ActOnDoStmt(SourceLocation DoLoc, StmtArg Body,
+ SourceLocation WhileLoc, ExprArg Cond) {
+ Expr *condExpr = (Expr *)Cond.release();
assert(condExpr && "ActOnDoStmt(): missing expression");
-
+
DefaultFunctionArrayConversion(condExpr);
+ Cond = condExpr;
QualType condType = condExpr->getType();
-
+
if (getLangOptions().CPlusPlus) {
if (CheckCXXBooleanCondition(condExpr)) // C++ 6.4p4
- return true;
+ return StmtError();
} else if (!condType->isScalarType()) // C99 6.8.5p2
- return Diag(DoLoc, diag::err_typecheck_statement_requires_scalar)
- << condType << condExpr->getSourceRange();
+ return StmtError(Diag(DoLoc, diag::err_typecheck_statement_requires_scalar)
+ << condType << condExpr->getSourceRange());
- return new DoStmt((Stmt*)Body, condExpr, DoLoc);
+ Cond.release();
+ return Owned(new DoStmt((Stmt*)Body.release(), condExpr, DoLoc));
}
-Action::StmtResult
-Sema::ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc,
- StmtTy *first, ExprTy *second, ExprTy *third,
- SourceLocation RParenLoc, StmtTy *body) {
- Stmt *First = static_cast<Stmt*>(first);
- Expr *Second = static_cast<Expr*>(second);
- Expr *Third = static_cast<Expr*>(third);
- Stmt *Body = static_cast<Stmt*>(body);
-
+Action::OwningStmtResult
+Sema::ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc,
+ StmtArg first, ExprArg second, ExprArg third,
+ SourceLocation RParenLoc, StmtArg body) {
+ Stmt *First = static_cast<Stmt*>(first.get());
+ Expr *Second = static_cast<Expr*>(second.get());
+ Expr *Third = static_cast<Expr*>(third.get());
+ Stmt *Body = static_cast<Stmt*>(body.get());
+
if (!getLangOptions().CPlusPlus) {
if (DeclStmt *DS = dyn_cast_or_null<DeclStmt>(First)) {
// C99 6.8.5p3: The declaration part of a 'for' statement shall only
if (Second) {
DefaultFunctionArrayConversion(Second);
QualType SecondType = Second->getType();
-
+
if (getLangOptions().CPlusPlus) {
if (CheckCXXBooleanCondition(Second)) // C++ 6.4p4
- return true;
+ return StmtError();
} else if (!SecondType->isScalarType()) // C99 6.8.5p2
- return Diag(ForLoc, diag::err_typecheck_statement_requires_scalar)
- << SecondType << Second->getSourceRange();
- }
- return new ForStmt(First, Second, Third, Body, ForLoc);
+ return StmtError(Diag(ForLoc,
+ diag::err_typecheck_statement_requires_scalar)
+ << SecondType << Second->getSourceRange());
+ }
+ first.release();
+ second.release();
+ third.release();
+ body.release();
+ return Owned(new ForStmt(First, Second, Third, Body, ForLoc));
}
-Action::StmtResult
-Sema::ActOnObjCForCollectionStmt(SourceLocation ForLoc,
- SourceLocation LParenLoc,
- StmtTy *first, ExprTy *second,
- SourceLocation RParenLoc, StmtTy *body) {
- Stmt *First = static_cast<Stmt*>(first);
- Expr *Second = static_cast<Expr*>(second);
- Stmt *Body = static_cast<Stmt*>(body);
+Action::OwningStmtResult
+Sema::ActOnObjCForCollectionStmt(SourceLocation ForLoc,
+ SourceLocation LParenLoc,
+ StmtArg first, ExprArg second,
+ SourceLocation RParenLoc, StmtArg body) {
+ Stmt *First = static_cast<Stmt*>(first.get());
+ Expr *Second = static_cast<Expr*>(second.get());
+ Stmt *Body = static_cast<Stmt*>(body.get());
if (First) {
QualType FirstType;
if (DeclStmt *DS = dyn_cast<DeclStmt>(First)) {
if (!DS->hasSolitaryDecl())
- return Diag((*DS->decl_begin())->getLocation(),
- diag::err_toomany_element_decls);
-
+ return StmtError(Diag((*DS->decl_begin())->getLocation(),
+ diag::err_toomany_element_decls));
+
ScopedDecl *D = DS->getSolitaryDecl();
FirstType = cast<ValueDecl>(D)->getType();
// C99 6.8.5p3: The declaration part of a 'for' statement shall only
// 'register'.
VarDecl *VD = cast<VarDecl>(D);
if (VD->isBlockVarDecl() && !VD->hasLocalStorage())
- return Diag(VD->getLocation(), diag::err_non_variable_decl_in_for);
+ return StmtError(Diag(VD->getLocation(),
+ diag::err_non_variable_decl_in_for));
} else {
Expr::isLvalueResult lval = cast<Expr>(First)->isLvalue(Context);
-
+
if (lval != Expr::LV_Valid)
- return Diag(First->getLocStart(), diag::err_selector_element_not_lvalue)
- << First->getSourceRange();
+ return StmtError(Diag(First->getLocStart(),
+ diag::err_selector_element_not_lvalue)
+ << First->getSourceRange());
- FirstType = static_cast<Expr*>(first)->getType();
+ FirstType = static_cast<Expr*>(First)->getType();
}
if (!Context.isObjCObjectPointerType(FirstType))
Diag(ForLoc, diag::err_selector_element_type)
Diag(ForLoc, diag::err_collection_expr_type)
<< SecondType << Second->getSourceRange();
}
- return new ObjCForCollectionStmt(First, Second, Body, ForLoc, RParenLoc);
+ first.release();
+ second.release();
+ body.release();
+ return Owned(new ObjCForCollectionStmt(First, Second, Body,
+ ForLoc, RParenLoc));
}
Action::StmtResult