OwningExprResult SelfExpr = ActOnIdentifierExpr(S, Loc, II, false);
return Owned(new (Context)
ObjCIvarRefExpr(IV, IV->getType(), Loc,
- static_cast<Expr*>(SelfExpr.release()),
- true, true));
+ SelfExpr.takeAs<Expr>(), true, true));
}
}
}
Action::OwningExprResult Sema::ActOnParenExpr(SourceLocation L,
SourceLocation R, ExprArg Val) {
- Expr *E = (Expr *)Val.release();
+ Expr *E = Val.takeAs<Expr>();
assert((E != 0) && "ActOnParenExpr() missing expr");
return Owned(new (Context) ParenExpr(L, R, E));
}
tok::TokenKind Kind,
ExprArg LHS, ExprArg RHS) {
BinaryOperator::Opcode Opc = ConvertTokenKindToBinaryOpcode(Kind);
- Expr *lhs = (Expr *)LHS.release(), *rhs = (Expr*)RHS.release();
+ Expr *lhs = LHS.takeAs<Expr>(), *rhs = RHS.takeAs<Expr>();
assert((lhs != 0) && "ActOnBinOp(): missing left expression");
assert((rhs != 0) && "ActOnBinOp(): missing right expression");
DiagnoseInvalidJumps(static_cast<CompoundStmt*>(body.get()));
CurFunctionNeedsScopeChecking = BSI->SavedFunctionNeedsScopeChecking;
- BSI->TheDecl->setBody(static_cast<CompoundStmt*>(body.release()));
+ BSI->TheDecl->setBody(body.takeAs<CompoundStmt>());
return Owned(new (Context) BlockExpr(BSI->TheDecl, BlockTy,
BSI->hasBlockDeclRefExprs));
}
Sema::ActOnIfStmt(SourceLocation IfLoc, ExprArg CondVal,
StmtArg ThenVal, SourceLocation ElseLoc,
StmtArg ElseVal) {
- Expr *condExpr = (Expr *)CondVal.release();
+ Expr *condExpr = CondVal.takeAs<Expr>();
assert(condExpr && "ActOnIfStmt(): missing expression");
return StmtError(Diag(IfLoc, diag::err_typecheck_statement_requires_scalar)
<< condType << condExpr->getSourceRange());
- Stmt *thenStmt = (Stmt *)ThenVal.release();
+ Stmt *thenStmt = ThenVal.takeAs<Stmt>();
// Warn if the if block has a null body without an else value.
// this helps prevent bugs due to typos, such as
CondVal.release();
return Owned(new (Context) IfStmt(IfLoc, condExpr, thenStmt,
- (Stmt*)ElseVal.release()));
+ ElseVal.takeAs<Stmt>()));
}
Action::OwningStmtResult
Action::OwningStmtResult
Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, StmtArg Switch,
StmtArg Body) {
- Stmt *BodyStmt = (Stmt*)Body.release();
+ Stmt *BodyStmt = Body.takeAs<Stmt>();
SwitchStmt *SS = getSwitchStack().back();
assert(SS == (SwitchStmt*)Switch.get() && "switch stack missing push/pop!");
Action::OwningStmtResult
Sema::ActOnWhileStmt(SourceLocation WhileLoc, ExprArg Cond, StmtArg Body) {
- Expr *condExpr = (Expr *)Cond.release();
+ Expr *condExpr = Cond.takeAs<Expr>();
assert(condExpr && "ActOnWhileStmt(): missing expression");
DefaultFunctionArrayConversion(condExpr);
<< condType << condExpr->getSourceRange());
Cond.release();
- return Owned(new (Context) WhileStmt(condExpr, (Stmt*)Body.release(),
+ return Owned(new (Context) WhileStmt(condExpr, Body.takeAs<Stmt>(),
WhileLoc));
}
Action::OwningStmtResult
Sema::ActOnDoStmt(SourceLocation DoLoc, StmtArg Body,
SourceLocation WhileLoc, ExprArg Cond) {
- Expr *condExpr = (Expr *)Cond.release();
+ Expr *condExpr = Cond.takeAs<Expr>();
assert(condExpr && "ActOnDoStmt(): missing expression");
DefaultFunctionArrayConversion(condExpr);
<< condType << condExpr->getSourceRange());
Cond.release();
- return Owned(new (Context) DoStmt((Stmt*)Body.release(), condExpr, DoLoc));
+ return Owned(new (Context) DoStmt(Body.takeAs<Stmt>(), condExpr, DoLoc));
}
Action::OwningStmtResult
}
ObjCAtCatchStmt *CS = new (Context) ObjCAtCatchStmt(AtLoc, RParen,
- PVD, static_cast<Stmt*>(Body.release()), CatchList);
+ PVD, Body.takeAs<Stmt>(), CatchList);
return Owned(CatchList ? CatchList : CS);
}
Sema::ActOnObjCAtTryStmt(SourceLocation AtLoc,
StmtArg Try, StmtArg Catch, StmtArg Finally) {
CurFunctionNeedsScopeChecking = true;
- return Owned(new (Context) ObjCAtTryStmt(AtLoc,
- static_cast<Stmt*>(Try.release()),
- static_cast<Stmt*>(Catch.release()),
- static_cast<Stmt*>(Finally.release())));
+ return Owned(new (Context) ObjCAtTryStmt(AtLoc, Try.takeAs<Stmt>(),
+ Catch.takeAs<Stmt>(),
+ Finally.takeAs<Stmt>()));
}
Action::OwningStmtResult
<< SyncExpr->getType() << SyncExpr->getSourceRange());
}
- return Owned(new (Context) ObjCAtSynchronizedStmt(AtLoc,
- static_cast<Stmt*>(SynchExpr.release()),
- static_cast<Stmt*>(SynchBody.release())));
+ return Owned(new (Context) ObjCAtSynchronizedStmt(AtLoc,
+ SynchExpr.takeAs<Stmt>(),
+ SynchBody.takeAs<Stmt>()));
}
/// ActOnCXXCatchBlock - Takes an exception declaration and a handler block
// There's nothing to test that ActOnExceptionDecl didn't already test.
return Owned(new (Context) CXXCatchStmt(CatchLoc,
cast_or_null<VarDecl>(ExDecl.getAs<Decl>()),
- static_cast<Stmt*>(HandlerBlock.release())));
+ HandlerBlock.takeAs<Stmt>()));
}
/// ActOnCXXTryBlock - Takes a try compound-statement and a number of