]> granicus.if.org Git - clang/commitdiff
ObjCAtCatchStmt's ParamStmt is always a DeclStmt.
authorDaniel Dunbar <daniel@zuster.org>
Sun, 1 Mar 2009 04:28:32 +0000 (04:28 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Sun, 1 Mar 2009 04:28:32 +0000 (04:28 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65759 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Stmt.h
lib/AST/Stmt.cpp
lib/CodeGen/CGObjCMac.cpp
lib/Sema/SemaStmt.cpp

index 696aa00ed77b5a454f4310057ebdd38fb1d46186..c4c2291f2c081d2d9d801750e4796866786b8d35 100644 (file)
@@ -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<ObjCAtCatchStmt*>(SubExprs[NEXT_CATCH]);
   }
 
-  const Stmt *getCatchParamStmt() const { return SubExprs[SELECTOR]; }
-  Stmt *getCatchParamStmt() { return SubExprs[SELECTOR]; }
+  const DeclStmt *getCatchParamStmt() const { 
+    return static_cast<const DeclStmt*>(SubExprs[SELECTOR]); }
+  DeclStmt *getCatchParamStmt() { 
+    return static_cast<DeclStmt*>(SubExprs[SELECTOR]); 
+  }
   
   SourceLocation getRParenLoc() const { return RParenLoc; }
   
index b85a67e689f8b7f22da4f3f195e54f9413c5a344..e987d84c23182c54b581dbcd4f84662648857cf6 100644 (file)
@@ -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<ObjCAtCatchStmt*>(atCatchList);
 
index 549a6b9f524137228b942ae1b7f3425740bad28e..26a11c90be5f7e736e51fef0def484cb7b13e121 100644 (file)
@@ -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<DeclStmt>(CatchStmt->getCatchParamStmt());
+      const DeclStmt *CatchParam = CatchStmt->getCatchParamStmt();
       const VarDecl *VD = 0;
       const PointerType *PT = 0;
 
index dfcb65a35323f97defdcdf94f1e00fea00f9d998..39b211f64b470a6127c7c43cc85b870d66b676d5 100644 (file)
@@ -964,7 +964,7 @@ Sema::ActOnObjCAtCatchStmt(SourceLocation AtLoc,
                            StmtArg Body, StmtArg catchList) {
   Stmt *CatchList = static_cast<Stmt*>(catchList.release());
   ObjCAtCatchStmt *CS = new (Context) ObjCAtCatchStmt(AtLoc, RParen,
-    static_cast<Stmt*>(Parm.release()), static_cast<Stmt*>(Body.release()),
+    static_cast<DeclStmt*>(Parm.release()), static_cast<Stmt*>(Body.release()),
     CatchList);
   return Owned(CatchList ? CatchList : CS);
 }