From: Daniel Dunbar Date: Fri, 6 Mar 2009 00:01:21 +0000 (+0000) Subject: Cleanup EH a bit given changes to ObjCCatchStmt. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ede8de95ebea858e65c79e54aa2455a394f27f13;p=clang Cleanup EH a bit given changes to ObjCCatchStmt. - No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66218 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp index 4d957ebd65..9b7bfc6ce7 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -4850,13 +4850,13 @@ CGObjCNonFragileABIMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF, SelectorArgs.push_back(ObjCTypes.EHPersonalityPtr); // Construct the lists of (type, catch body) to handle. - llvm::SmallVector, 8> Handlers; + llvm::SmallVector, 8> Handlers; bool HasCatchAll = false; if (isTry) { if (const ObjCAtCatchStmt* CatchStmt = cast(S).getCatchStmts()) { for (; CatchStmt; CatchStmt = CatchStmt->getNextCatchStmt()) { - const Decl *CatchDecl = CatchStmt->getCatchParamDecl(); + const ParmVarDecl *CatchDecl = CatchStmt->getCatchParamDecl(); Handlers.push_back(std::make_pair(CatchDecl, CatchStmt->getCatchBody())); // catch(...) always matches. @@ -4868,9 +4868,8 @@ CGObjCNonFragileABIMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF, break; } - const VarDecl *VD = cast(CatchDecl); - if (CGF.getContext().isObjCIdType(VD->getType()) || - VD->getType()->isObjCQualifiedIdType()) { + if (CGF.getContext().isObjCIdType(CatchDecl->getType()) || + CatchDecl->getType()->isObjCQualifiedIdType()) { llvm::Value *IDEHType = CGM.getModule().getGlobalVariable("OBJC_EHTYPE_id"); if (!IDEHType) @@ -4884,7 +4883,7 @@ CGObjCNonFragileABIMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF, } // All other types should be Objective-C interface pointer types. - const PointerType *PT = VD->getType()->getAsPointerType(); + const PointerType *PT = CatchDecl->getType()->getAsPointerType(); assert(PT && "Invalid @catch type."); const ObjCInterfaceType *IT = PT->getPointeeType()->getAsObjCInterfaceType(); @@ -4898,7 +4897,7 @@ CGObjCNonFragileABIMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF, // We use a cleanup unless there was already a catch all. if (!HasCatchAll) { SelectorArgs.push_back(llvm::ConstantInt::get(llvm::Type::Int32Ty, 0)); - Handlers.push_back(std::make_pair((const Decl*) 0, (const Stmt*) 0)); + Handlers.push_back(std::make_pair((const ParmVarDecl*) 0, (const Stmt*) 0)); } llvm::Value *Selector = @@ -4906,7 +4905,7 @@ CGObjCNonFragileABIMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF, SelectorArgs.begin(), SelectorArgs.end(), "selector"); for (unsigned i = 0, e = Handlers.size(); i != e; ++i) { - const Decl *CatchParam = Handlers[i].first; + const ParmVarDecl *CatchParam = Handlers[i].first; const Stmt *CatchBody = Handlers[i].second; llvm::BasicBlock *Next = 0; @@ -4943,11 +4942,14 @@ CGObjCNonFragileABIMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF, // Bind the catch parameter if it exists. if (CatchParam) { - const VarDecl *VD = dyn_cast(CatchParam); - ExcObject = CGF.Builder.CreateBitCast(ExcObject, - CGF.ConvertType(VD->getType())); - CGF.EmitLocalBlockVarDecl(*VD); - CGF.Builder.CreateStore(ExcObject, CGF.GetAddrOfLocalVar(VD)); + ExcObject = + CGF.Builder.CreateBitCast(ExcObject, + CGF.ConvertType(CatchParam->getType())); + // CatchParam is a ParmVarDecl because of the grammar + // construction used to handle this, but for codegen purposes + // we treat this as a local decl. + CGF.EmitLocalBlockVarDecl(*CatchParam); + CGF.Builder.CreateStore(ExcObject, CGF.GetAddrOfLocalVar(CatchParam)); } CGF.ObjCEHValueStack.push_back(ExcObject);