From: Daniel Dunbar Date: Tue, 5 May 2009 00:36:57 +0000 (+0000) Subject: Remove an unneeded lookup routine. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a81419d0b53a40399a589a2fcc13f1ed2ec28f75;p=clang Remove an unneeded lookup routine. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70951 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp index 1f58389ab8..5571f0f558 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -43,8 +43,6 @@ static const ObjCInterfaceDecl *FindIvarInterface(ASTContext &Context, const ObjCInterfaceDecl *OID, const ObjCIvarDecl *OIVD, unsigned &Index) { - const ObjCInterfaceDecl *Super = OID->getSuperClass(); - // FIXME: The index here is closely tied to how // ASTContext::getObjCLayout is implemented. This should be fixed to // get the information from the layout directly. @@ -65,7 +63,7 @@ static const ObjCInterfaceDecl *FindIvarInterface(ASTContext &Context, } // Otherwise check in the super class. - if (Super) + if (const ObjCInterfaceDecl *Super = OID->getSuperClass()) return FindIvarInterface(Context, Super, OIVD, Index); return 0; @@ -2061,35 +2059,6 @@ CGObjCMac::EmitClassExtension(const ObjCImplementationDecl *ID) { 4, true); } -/// getInterfaceDeclForIvar - Get the interface declaration node where -/// this ivar is declared in. -/// FIXME. Ideally, this info should be in the ivar node. But currently -/// it is not and prevailing wisdom is that ASTs should not have more -/// info than is absolutely needed, even though this info reflects the -/// source language. -/// -static const ObjCInterfaceDecl *getInterfaceDeclForIvar( - const ObjCInterfaceDecl *OI, - const ObjCIvarDecl *IVD, - ASTContext &Context) { - if (!OI) - return 0; - assert(isa(OI) && "OI is not an interface"); - for (ObjCInterfaceDecl::ivar_iterator I = OI->ivar_begin(), - E = OI->ivar_end(); I != E; ++I) - if ((*I)->getIdentifier() == IVD->getIdentifier()) - return OI; - // look into properties. - for (ObjCInterfaceDecl::prop_iterator I = OI->prop_begin(Context), - E = OI->prop_end(Context); I != E; ++I) { - ObjCPropertyDecl *PDecl = (*I); - if (ObjCIvarDecl *IV = PDecl->getPropertyIvarDecl()) - if (IV->getIdentifier() == IVD->getIdentifier()) - return OI; - } - return getInterfaceDeclForIvar(OI->getSuperClass(), IVD, Context); -} - /* struct objc_ivar { char *ivar_name; @@ -4511,12 +4480,15 @@ llvm::Constant *CGObjCNonFragileABIMac::EmitMethodList( /// ObjCIvarOffsetVariable - Returns the ivar offset variable for /// the given ivar. -/// llvm::GlobalVariable * CGObjCNonFragileABIMac::ObjCIvarOffsetVariable( const ObjCInterfaceDecl *ID, const ObjCIvarDecl *Ivar) { - std::string Name = "OBJC_IVAR_$_" + - getInterfaceDeclForIvar(ID, Ivar, CGM.getContext())->getNameAsString() + + // FIXME: We shouldn't need to do this lookup. + unsigned Index; + const ObjCInterfaceDecl *Container = + FindIvarInterface(CGM.getContext(), ID, Ivar, Index); + assert(Container && "Unable to find ivar container!"); + std::string Name = "OBJC_IVAR_$_" + Container->getNameAsString() + '.' + Ivar->getNameAsString(); llvm::GlobalVariable *IvarOffsetGV = CGM.getModule().getGlobalVariable(Name);