Replace a bunch of static_cast + release with takeAs.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70566 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Anders Carlsson 2009-05-01 19:30:39 +00:00
Родитель a8607d13c8
Коммит f1b1d59a3f
5 изменённых файлов: 17 добавлений и 17 удалений

Просмотреть файл

@ -2485,7 +2485,7 @@ void Sema::AddInitializerToDecl(DeclPtrTy dcl, ExprArg init, bool DirectInit) {
// Take ownership of the expression, now that we're sure we have somewhere
// to put it.
Expr *Init = static_cast<Expr *>(init.release());
Expr *Init = init.takeAs<Expr>();
assert(Init && "missing initializer");
// Get the decls type and save a reference for later, since
@ -4274,7 +4274,7 @@ void Sema::ActOnEnumBody(SourceLocation EnumLoc, DeclPtrTy EnumDeclX,
Sema::DeclPtrTy Sema::ActOnFileScopeAsmDecl(SourceLocation Loc,
ExprArg expr) {
StringLiteral *AsmString = cast<StringLiteral>((Expr*)expr.release());
StringLiteral *AsmString = cast<StringLiteral>(expr.takeAs<Expr>());
return DeclPtrTy::make(FileScopeAsmDecl::Create(Context, CurContext,
Loc, AsmString));

Просмотреть файл

@ -108,7 +108,7 @@ void
Sema::ActOnParamDefaultArgument(DeclPtrTy param, SourceLocation EqualLoc,
ExprArg defarg) {
ParmVarDecl *Param = cast<ParmVarDecl>(param.getAs<Decl>());
ExprOwningPtr<Expr> DefaultArg(this, (Expr *)defarg.release());
ExprOwningPtr<Expr> DefaultArg(this, defarg.takeAs<Expr>());
QualType ParamType = Param->getType();
// Default arguments are only permitted in C++

Просмотреть файл

@ -1852,7 +1852,7 @@ Sema::ActOnMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
tok::TokenKind OpKind, SourceLocation MemberLoc,
IdentifierInfo &Member,
DeclPtrTy ObjCImpDecl) {
Expr *BaseExpr = static_cast<Expr *>(Base.release());
Expr *BaseExpr = Base.takeAs<Expr>();
assert(BaseExpr && "no record expression");
// Perform default conversions.
@ -2322,7 +2322,7 @@ Sema::ActOnCallExpr(Scope *S, ExprArg fn, SourceLocation LParenLoc,
MultiExprArg args,
SourceLocation *CommaLocs, SourceLocation RParenLoc) {
unsigned NumArgs = args.size();
Expr *Fn = static_cast<Expr *>(fn.release());
Expr *Fn = fn.takeAs<Expr>();
Expr **Args = reinterpret_cast<Expr**>(args.release());
assert(Fn && "no function call expression");
FunctionDecl *FDecl = NULL;
@ -2643,7 +2643,7 @@ Sema::ActOnCastExpr(SourceLocation LParenLoc, TypeTy *Ty,
assert((Ty != 0) && (Op.get() != 0) &&
"ActOnCastExpr(): missing type or expr");
Expr *castExpr = static_cast<Expr*>(Op.release());
Expr *castExpr = Op.takeAs<Expr>();
QualType castType = QualType::getFromOpaquePtr(Ty);
if (CheckCastTypes(SourceRange(LParenLoc, RParenLoc), castType, castExpr))
@ -4715,8 +4715,8 @@ Sema::OwningExprResult Sema::ActOnBuiltinOffsetOf(Scope *S,
// FIXME: C++: Verify that MemberDecl isn't a static field.
// FIXME: Verify that MemberDecl isn't a bitfield.
if (cast<RecordDecl>(MemberDecl->getDeclContext())->isAnonymousStructOrUnion()) {
Res = static_cast<Expr*>(BuildAnonymousStructUnionMemberReference(
SourceLocation(), MemberDecl, Res, SourceLocation()).release());
Res = BuildAnonymousStructUnionMemberReference(
SourceLocation(), MemberDecl, Res, SourceLocation()).takeAs<Expr>();
} else {
// MemberDecl->getType() doesn't get the right qualifiers, but it
// doesn't matter here.

Просмотреть файл

@ -22,7 +22,7 @@
using namespace clang;
Sema::OwningStmtResult Sema::ActOnExprStmt(ExprArg expr) {
Expr *E = static_cast<Expr*>(expr.release());
Expr *E = expr.takeAs<Expr>();
assert(E && "ActOnExprStmt(): missing expression");
// C99 6.8.3p2: The expression in an expression statement is evaluated as a
@ -129,14 +129,14 @@ Sema::ActOnCaseStmt(SourceLocation CaseLoc, ExprArg lhsval,
/// ActOnCaseStmtBody - This installs a statement as the body of a case.
void Sema::ActOnCaseStmtBody(StmtTy *caseStmt, StmtArg subStmt) {
CaseStmt *CS = static_cast<CaseStmt*>(caseStmt);
Stmt *SubStmt = static_cast<Stmt*>(subStmt.release());
Stmt *SubStmt = subStmt.takeAs<Stmt>();
CS->setSubStmt(SubStmt);
}
Action::OwningStmtResult
Sema::ActOnDefaultStmt(SourceLocation DefaultLoc, SourceLocation ColonLoc,
StmtArg subStmt, Scope *CurScope) {
Stmt *SubStmt = static_cast<Stmt*>(subStmt.release());
Stmt *SubStmt = subStmt.takeAs<Stmt>();
if (getSwitchStack().empty()) {
Diag(DefaultLoc, diag::err_default_not_in_switch);
@ -151,7 +151,7 @@ Sema::ActOnDefaultStmt(SourceLocation DefaultLoc, SourceLocation ColonLoc,
Action::OwningStmtResult
Sema::ActOnLabelStmt(SourceLocation IdentLoc, IdentifierInfo *II,
SourceLocation ColonLoc, StmtArg subStmt) {
Stmt *SubStmt = static_cast<Stmt*>(subStmt.release());
Stmt *SubStmt = subStmt.takeAs<Stmt>();
// Look up the record for this label identifier.
LabelStmt *&LabelDecl = getLabelMap()[II];
@ -214,7 +214,7 @@ Sema::ActOnIfStmt(SourceLocation IfLoc, ExprArg CondVal,
Action::OwningStmtResult
Sema::ActOnStartOfSwitchStmt(ExprArg cond) {
Expr *Cond = static_cast<Expr*>(cond.release());
Expr *Cond = cond.takeAs<Expr>();
if (getLangOptions().CPlusPlus) {
// C++ 6.4.2.p2:
@ -788,7 +788,7 @@ static bool IsReturnCopyElidable(ASTContext &Ctx, QualType RetType,
Action::OwningStmtResult
Sema::ActOnReturnStmt(SourceLocation ReturnLoc, ExprArg rex) {
Expr *RetValExp = static_cast<Expr *>(rex.release());
Expr *RetValExp = rex.takeAs<Expr>();
if (CurBlock)
return ActOnBlockReturnStmt(ReturnLoc, RetValExp);
@ -1051,7 +1051,7 @@ Action::OwningStmtResult
Sema::ActOnObjCAtCatchStmt(SourceLocation AtLoc,
SourceLocation RParen, DeclPtrTy Parm,
StmtArg Body, StmtArg catchList) {
Stmt *CatchList = static_cast<Stmt*>(catchList.release());
Stmt *CatchList = catchList.takeAs<Stmt>();
ParmVarDecl *PVD = cast_or_null<ParmVarDecl>(Parm.getAs<Decl>());
// PVD == 0 implies @catch(...).
@ -1091,7 +1091,7 @@ Sema::ActOnObjCAtTryStmt(SourceLocation AtLoc,
Action::OwningStmtResult
Sema::ActOnObjCAtThrowStmt(SourceLocation AtLoc, ExprArg expr,Scope *CurScope) {
Expr *ThrowExpr = static_cast<Expr*>(expr.release());
Expr *ThrowExpr = expr.takeAs<Expr>();
if (!ThrowExpr) {
// @throw without an expression designates a rethrow (which much occur
// in the context of an @catch clause).

Просмотреть файл

@ -465,7 +465,7 @@ InstantiateTemplateSpecializationType(
NumTemplateArgs);
if (E.isInvalid())
return QualType();
InstantiatedTemplateArgs.push_back((Expr *)E.release());
InstantiatedTemplateArgs.push_back(E.takeAs<Expr>());
break;
}
}