diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-03-06 00:01:21 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-03-06 00:01:21 +0000 |
commit | ede8de95ebea858e65c79e54aa2455a394f27f13 (patch) | |
tree | 976f4c92841397d77bf6d4c70c36ef301c78c2eb /lib/CodeGen/CGObjCMac.cpp | |
parent | e6ee6bab61ab61eeceb3572bd5a9f85a9424eb9f (diff) |
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
Diffstat (limited to 'lib/CodeGen/CGObjCMac.cpp')
-rw-r--r-- | lib/CodeGen/CGObjCMac.cpp | 28 |
1 files changed, 15 insertions, 13 deletions
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<std::pair<const Decl*, const Stmt*>, 8> Handlers; + llvm::SmallVector<std::pair<const ParmVarDecl*, const Stmt*>, 8> Handlers; bool HasCatchAll = false; if (isTry) { if (const ObjCAtCatchStmt* CatchStmt = cast<ObjCAtTryStmt>(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<VarDecl>(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<VarDecl>(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); |