]> granicus.if.org Git - clang/commitdiff
Replace a bunch of static_cast + release with takeAs.
authorAnders Carlsson <andersca@mac.com>
Fri, 1 May 2009 19:30:39 +0000 (19:30 +0000)
committerAnders Carlsson <andersca@mac.com>
Fri, 1 May 2009 19:30:39 +0000 (19:30 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70566 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
lib/Sema/SemaDeclCXX.cpp
lib/Sema/SemaExpr.cpp
lib/Sema/SemaStmt.cpp
lib/Sema/SemaTemplateInstantiate.cpp

index de509246ba5b106cb7f5a6b086ba0d4883ed7c31..af27229b92bf60e92b60ec960220f65005530f0f 100644 (file)
@@ -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));
index 54c887e303b566dc11017ad08e020ee021603922..cc633e738d75d03e36aa8024291b4f3a2a434286 100644 (file)
@@ -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++
index 66b4c9c6b2c6acbb34632061a589bd461f265a5f..5c0c33b298c567d783402eb2d2ad4abdf67b1fe9 100644 (file)
@@ -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.
index fff7a44bc404583f246dd83f957ca2374bc0e653..d7fd5f054d079125e75bdfe663aded010a6f3074 100644 (file)
@@ -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).
index bd385d355bc6c13cc412205f7476c7c6829b7b0a..137868291997d05d34e52194b8eec62952b51b9c 100644 (file)
@@ -465,7 +465,7 @@ InstantiateTemplateSpecializationType(
                                   NumTemplateArgs);
       if (E.isInvalid())
         return QualType();
-      InstantiatedTemplateArgs.push_back((Expr *)E.release());
+      InstantiatedTemplateArgs.push_back(E.takeAs<Expr>());
       break;
     }
   }