diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-04-07 06:43:45 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-04-07 06:43:45 +0000 |
commit | 7e075cb62c06e0b0023fd12875c95da9c5ddefb7 (patch) | |
tree | fe6b858b895b553cf49b163fceac73d4a25b401e /lib/CodeGen/CGObjCMac.cpp | |
parent | 7f48c6e0f0377fbea062515759a7477c7be70b0d (diff) |
Handle use side of __objc_exception__ attribute; when using an
exception with this attribute we don't need to emit a weak definition
for the exception type information.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68513 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGObjCMac.cpp')
-rw-r--r-- | lib/CodeGen/CGObjCMac.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp index cf2d8da022..f410e213cb 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -5547,6 +5547,14 @@ void CGObjCNonFragileABIMac::EmitThrowStmt(CodeGen::CodeGenFunction &CGF, CGF.Builder.ClearInsertionPoint(); } +static bool hasObjCExceptionAttribute(const ObjCInterfaceDecl *OID) { + if (OID->getAttr<ObjCExceptionAttr>()) + return true; + if (const ObjCInterfaceDecl *Super = OID->getSuperClass()) + return hasObjCExceptionAttribute(Super); + return false; +} + llvm::Value * CGObjCNonFragileABIMac::GetInterfaceEHType(const ObjCInterfaceType *IT) { const ObjCInterfaceDecl *ID = IT->getDecl(); @@ -5554,6 +5562,17 @@ CGObjCNonFragileABIMac::GetInterfaceEHType(const ObjCInterfaceType *IT) { if (Entry) return Entry; + // If this type (or a super class) has the __objc_exception__ + // attribute, emit an external reference. + if (hasObjCExceptionAttribute(IT->getDecl())) + return Entry = + new llvm::GlobalVariable(ObjCTypes.EHTypeTy, false, + llvm::GlobalValue::ExternalLinkage, + 0, + (std::string("OBJC_EHTYPE_$_") + + ID->getIdentifier()->getName()), + &CGM.getModule()); + std::string ClassName(getClassSymbolPrefix() + ID->getNameAsString()); std::string VTableName = "objc_ehtype_vtable"; llvm::GlobalVariable *VTableGV = |