From 93b2bdb866d49e3dab4623a822db281042e87382 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Sun, 1 Mar 2009 04:28:32 +0000 Subject: [PATCH] ObjCAtCatchStmt's ParamStmt is always a DeclStmt. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65759 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/Stmt.h | 10 +++++++--- lib/AST/Stmt.cpp | 3 ++- lib/CodeGen/CGObjCMac.cpp | 3 +-- lib/Sema/SemaStmt.cpp | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h index 696aa00ed7..c4c2291f2c 100644 --- a/include/clang/AST/Stmt.h +++ b/include/clang/AST/Stmt.h @@ -1066,7 +1066,8 @@ private: public: ObjCAtCatchStmt(SourceLocation atCatchLoc, SourceLocation rparenloc, - Stmt *catchVarStmtDecl, Stmt *atCatchStmt, Stmt *atCatchList); + DeclStmt *catchVarStmtDecl, + Stmt *atCatchStmt, Stmt *atCatchList); const Stmt *getCatchBody() const { return SubExprs[BODY]; } Stmt *getCatchBody() { return SubExprs[BODY]; } @@ -1078,8 +1079,11 @@ public: return static_cast(SubExprs[NEXT_CATCH]); } - const Stmt *getCatchParamStmt() const { return SubExprs[SELECTOR]; } - Stmt *getCatchParamStmt() { return SubExprs[SELECTOR]; } + const DeclStmt *getCatchParamStmt() const { + return static_cast(SubExprs[SELECTOR]); } + DeclStmt *getCatchParamStmt() { + return static_cast(SubExprs[SELECTOR]); + } SourceLocation getRParenLoc() const { return RParenLoc; } diff --git a/lib/AST/Stmt.cpp b/lib/AST/Stmt.cpp index b85a67e689..e987d84c23 100644 --- a/lib/AST/Stmt.cpp +++ b/lib/AST/Stmt.cpp @@ -180,12 +180,13 @@ ObjCForCollectionStmt::ObjCForCollectionStmt(Stmt *Elem, Expr *Collect, ObjCAtCatchStmt::ObjCAtCatchStmt(SourceLocation atCatchLoc, SourceLocation rparenloc, - Stmt *catchVarStmtDecl, Stmt *atCatchStmt, + DeclStmt *catchVarStmtDecl, Stmt *atCatchStmt, Stmt *atCatchList) : Stmt(ObjCAtCatchStmtClass) { SubExprs[SELECTOR] = catchVarStmtDecl; SubExprs[BODY] = atCatchStmt; SubExprs[NEXT_CATCH] = NULL; + // FIXME: O(N^2) in number of catch blocks. if (atCatchList) { ObjCAtCatchStmt *AtCatchList = static_cast(atCatchList); diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp index 549a6b9f52..26a11c90be 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -1999,8 +1999,7 @@ void CGObjCMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF, for (; CatchStmt; CatchStmt = CatchStmt->getNextCatchStmt()) { llvm::BasicBlock *NextCatchBlock = CGF.createBasicBlock("catch"); - const DeclStmt *CatchParam = - cast_or_null(CatchStmt->getCatchParamStmt()); + const DeclStmt *CatchParam = CatchStmt->getCatchParamStmt(); const VarDecl *VD = 0; const PointerType *PT = 0; diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index dfcb65a353..39b211f64b 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -964,7 +964,7 @@ Sema::ActOnObjCAtCatchStmt(SourceLocation AtLoc, StmtArg Body, StmtArg catchList) { Stmt *CatchList = static_cast(catchList.release()); ObjCAtCatchStmt *CS = new (Context) ObjCAtCatchStmt(AtLoc, RParen, - static_cast(Parm.release()), static_cast(Body.release()), + static_cast(Parm.release()), static_cast(Body.release()), CatchList); return Owned(CatchList ? CatchList : CS); } -- 2.40.0