From: Douglas Gregor Date: Mon, 26 Apr 2010 16:46:50 +0000 (+0000) Subject: Make the static type of the exception variable in an Objective-C X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c00d8e18ad3d903acfeb5d05163ce90713066a3f;p=clang Make the static type of the exception variable in an Objective-C @catch a VarDecl. The dynamic type is still a ParmVarDecl, but that will change soon. No effective functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102341 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/StmtObjC.h b/include/clang/AST/StmtObjC.h index 6cb2b1f18a..269aa4c6da 100644 --- a/include/clang/AST/StmtObjC.h +++ b/include/clang/AST/StmtObjC.h @@ -71,13 +71,13 @@ public: /// ObjCAtCatchStmt - This represents objective-c's @catch statement. class ObjCAtCatchStmt : public Stmt { private: - ParmVarDecl *ExceptionDecl; + VarDecl *ExceptionDecl; Stmt *Body; SourceLocation AtCatchLoc, RParenLoc; public: ObjCAtCatchStmt(SourceLocation atCatchLoc, SourceLocation rparenloc, - ParmVarDecl *catchVarDecl, + VarDecl *catchVarDecl, Stmt *atCatchStmt) : Stmt(ObjCAtCatchStmtClass), ExceptionDecl(catchVarDecl), Body(atCatchStmt), AtCatchLoc(atCatchLoc), RParenLoc(rparenloc) { } @@ -89,13 +89,13 @@ public: Stmt *getCatchBody() { return Body; } void setCatchBody(Stmt *S) { Body = S; } - const ParmVarDecl *getCatchParamDecl() const { + const VarDecl *getCatchParamDecl() const { return ExceptionDecl; } - ParmVarDecl *getCatchParamDecl() { + VarDecl *getCatchParamDecl() { return ExceptionDecl; } - void setCatchParamDecl(ParmVarDecl *D) { ExceptionDecl = D; } + void setCatchParamDecl(VarDecl *D) { ExceptionDecl = D; } SourceLocation getAtCatchLoc() const { return AtCatchLoc; } void setAtCatchLoc(SourceLocation Loc) { AtCatchLoc = Loc; } diff --git a/lib/AST/StmtDumper.cpp b/lib/AST/StmtDumper.cpp index f8b8173519..ca62ed12d0 100644 --- a/lib/AST/StmtDumper.cpp +++ b/lib/AST/StmtDumper.cpp @@ -555,7 +555,7 @@ void StmtDumper::VisitObjCMessageExpr(ObjCMessageExpr* Node) { void StmtDumper::VisitObjCAtCatchStmt(ObjCAtCatchStmt *Node) { DumpStmt(Node); - if (ParmVarDecl *CatchParam = Node->getCatchParamDecl()) { + if (VarDecl *CatchParam = Node->getCatchParamDecl()) { OS << " catch parm = "; DumpDeclarator(CatchParam); } else { diff --git a/lib/CodeGen/CGObjCGNU.cpp b/lib/CodeGen/CGObjCGNU.cpp index a248c5a1be..e8ade2adb1 100644 --- a/lib/CodeGen/CGObjCGNU.cpp +++ b/lib/CodeGen/CGObjCGNU.cpp @@ -1773,7 +1773,7 @@ void CGObjCGNU::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF, llvm::Value *RethrowPtr = CGF.CreateTempAlloca(Exc->getType(), "_rethrow"); llvm::SmallVector ESelArgs; - llvm::SmallVector, 8> Handlers; + llvm::SmallVector, 8> Handlers; ESelArgs.push_back(Exc); ESelArgs.push_back(Personality); @@ -1787,7 +1787,7 @@ void CGObjCGNU::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF, for (unsigned I = 0, N = AtTry.getNumCatchStmts(); I != N; ++I) { const ObjCAtCatchStmt *CatchStmt = AtTry.getCatchStmt(I); - const ParmVarDecl *CatchDecl = CatchStmt->getCatchParamDecl(); + const VarDecl *CatchDecl = CatchStmt->getCatchParamDecl(); Handlers.push_back(std::make_pair(CatchDecl, CatchStmt->getCatchBody())); @@ -1826,7 +1826,7 @@ void CGObjCGNU::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF, ESelArgs.begin(), ESelArgs.end(), "selector"); for (unsigned i = 0, e = Handlers.size(); i != e; ++i) { - const ParmVarDecl *CatchParam = Handlers[i].first; + const VarDecl *CatchParam = Handlers[i].first; const Stmt *CatchBody = Handlers[i].second; llvm::BasicBlock *Next = 0; diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp index 62e7900533..3905bd4f3d 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -2670,7 +2670,7 @@ void CGObjCMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF, const ObjCAtCatchStmt *CatchStmt = AtTryStmt->getCatchStmt(I); llvm::BasicBlock *NextCatchBlock = CGF.createBasicBlock("catch"); - const ParmVarDecl *CatchParam = CatchStmt->getCatchParamDecl(); + const VarDecl *CatchParam = CatchStmt->getCatchParamDecl(); const ObjCObjectPointerType *OPT = 0; // catch(...) always matches. @@ -5562,13 +5562,13 @@ CGObjCNonFragileABIMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF, SelectorArgs.push_back(ObjCTypes.getEHPersonalityPtr()); // Construct the lists of (type, catch body) to handle. - llvm::SmallVector, 8> Handlers; + llvm::SmallVector, 8> Handlers; bool HasCatchAll = false; if (isTry) { const ObjCAtTryStmt &AtTry = cast(S); for (unsigned I = 0, N = AtTry.getNumCatchStmts(); I != N; ++I) { const ObjCAtCatchStmt *CatchStmt = AtTry.getCatchStmt(I); - const ParmVarDecl *CatchDecl = CatchStmt->getCatchParamDecl(); + const VarDecl *CatchDecl = CatchStmt->getCatchParamDecl(); Handlers.push_back(std::make_pair(CatchDecl, CatchStmt->getCatchBody())); // catch(...) always matches. @@ -5618,7 +5618,7 @@ CGObjCNonFragileABIMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF, SelectorArgs.begin(), SelectorArgs.end(), "selector"); for (unsigned i = 0, e = Handlers.size(); i != e; ++i) { - const ParmVarDecl *CatchParam = Handlers[i].first; + const VarDecl *CatchParam = Handlers[i].first; const Stmt *CatchBody = Handlers[i].second; llvm::BasicBlock *Next = 0; diff --git a/lib/Frontend/PCHReaderStmt.cpp b/lib/Frontend/PCHReaderStmt.cpp index cf26b6e237..5e08be138a 100644 --- a/lib/Frontend/PCHReaderStmt.cpp +++ b/lib/Frontend/PCHReaderStmt.cpp @@ -839,7 +839,7 @@ unsigned PCHStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) { unsigned PCHStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) { VisitStmt(S); S->setCatchBody(cast_or_null(StmtStack.back())); - S->setCatchParamDecl(cast_or_null(Reader.GetDecl(Record[Idx++]))); + S->setCatchParamDecl(cast_or_null(Reader.GetDecl(Record[Idx++]))); S->setAtCatchLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); S->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); return 1; diff --git a/lib/Frontend/RewriteObjC.cpp b/lib/Frontend/RewriteObjC.cpp index 5f3b27201f..a1cbb324c4 100644 --- a/lib/Frontend/RewriteObjC.cpp +++ b/lib/Frontend/RewriteObjC.cpp @@ -1881,7 +1881,7 @@ Stmt *RewriteObjC::RewriteObjCTryStmt(ObjCAtTryStmt *S) { Stmt *lastCatchBody = 0; for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I) { ObjCAtCatchStmt *Catch = S->getCatchStmt(I); - ParmVarDecl *catchDecl = Catch->getCatchParamDecl(); + VarDecl *catchDecl = Catch->getCatchParamDecl(); if (I == 0) buf = "if ("; // we are generating code for the first catch clause diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index 9a223e91dc..8ee5d3292e 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -1711,6 +1711,6 @@ Sema::DeclPtrTy Sema::ActOnObjCExceptionDecl(Scope *S, Declarator &D) { // FIXME: Perform checking on the declaration here. DeclPtrTy Dcl = ActOnParamDeclarator(S, D); if (Dcl.get()) - cast(Dcl.getAs())->setDeclContext(CurContext); + cast(Dcl.getAs())->setDeclContext(CurContext); return Dcl; }