[cfe-commits] r55143 - in /cfe/trunk: include/clang/AST/DeclObjC.h lib/CodeGen/CGObjCMac.cpp
Daniel Dunbar
daniel at zuster.org
Thu Aug 21 14:57:41 PDT 2008
Author: ddunbar
Date: Thu Aug 21 16:57:41 2008
New Revision: 55143
URL: http://llvm.org/viewvc/llvm-project?rev=55143&view=rev
Log:
NeXT: Emit [meta]class protocol references.
Updated ObjCProtocolDecl::protocol_iterator to match that of
ObjCInterfaceDecl.
Modified:
cfe/trunk/include/clang/AST/DeclObjC.h
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=55143&r1=55142&r2=55143&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Thu Aug 21 16:57:41 2008
@@ -596,7 +596,7 @@
const ObjCList<ObjCProtocolDecl> &getReferencedProtocols() const {
return ReferencedProtocols;
}
- typedef ObjCProtocolDecl * const * protocol_iterator;
+ typedef ObjCList<ObjCProtocolDecl>::iterator protocol_iterator;
protocol_iterator protocol_begin() const {return ReferencedProtocols.begin();}
protocol_iterator protocol_end() const { return ReferencedProtocols.end(); }
Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=55143&r1=55142&r2=55143&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Thu Aug 21 16:57:41 2008
@@ -234,7 +234,9 @@
/// EmitProtocolList - Generate the list of referenced
/// protocols. The return value has type ProtocolListPtrTy.
- llvm::Constant *EmitProtocolList(const ObjCProtocolDecl *PD);
+ llvm::Constant *EmitProtocolList(const std::string &Name,
+ ObjCProtocolDecl::protocol_iterator begin,
+ ObjCProtocolDecl::protocol_iterator end);
/// EmitSelector - Return a Value*, of type ObjCTypes.SelectorPtrTy,
/// for the given selector.
@@ -459,7 +461,10 @@
std::vector<llvm::Constant*> Values(5);
Values[0] = EmitProtocolExtension(PD);
Values[1] = GetClassName(PD->getIdentifier());
- Values[2] = EmitProtocolList(PD);
+ Values[2] =
+ EmitProtocolList(std::string("\01L_OBJC_PROTOCOL_REFS_")+PD->getName(),
+ PD->protocol_begin(),
+ PD->protocol_end());
Values[3] = EmitMethodDescList(ProtocolName,
true, // IsProtocol
false, // ClassMethods
@@ -577,12 +582,14 @@
Protocol *list[];
};
*/
-llvm::Constant *CGObjCMac::EmitProtocolList(const ObjCProtocolDecl *PD) {
+llvm::Constant *
+CGObjCMac::EmitProtocolList(const std::string &Name,
+ ObjCProtocolDecl::protocol_iterator begin,
+ ObjCProtocolDecl::protocol_iterator end) {
std::vector<llvm::Constant*> ProtocolRefs;
- for (ObjCProtocolDecl::protocol_iterator i = PD->protocol_begin(),
- e = PD->protocol_end(); i != e; ++i)
- ProtocolRefs.push_back(GetProtocolRef(*i));
+ for (; begin != end; ++begin)
+ ProtocolRefs.push_back(GetProtocolRef(*begin));
// Just return null for empty protocol lists
if (ProtocolRefs.empty())
@@ -605,8 +612,7 @@
new llvm::GlobalVariable(Init->getType(), false,
llvm::GlobalValue::InternalLinkage,
Init,
- (std::string("\01L_OBJC_PROTOCOL_REFS_") +
- PD->getName()),
+ Name,
&CGM.getModule());
GV->setSection("__OBJC,__cat_cls_meth,regular,no_dead_strip");
return llvm::ConstantExpr::getBitCast(GV, ObjCTypes.ProtocolListPtrTy);
@@ -728,12 +734,13 @@
*/
void CGObjCMac::GenerateClass(const ObjCImplementationDecl *ID) {
const char *ClassName = ID->getName();
- // FIXME: Support protocols.
- llvm::Constant *Protocols =
- llvm::Constant::getNullValue(ObjCTypes.ProtocolListPtrTy);
// FIXME: Gross
ObjCInterfaceDecl *Interface =
const_cast<ObjCInterfaceDecl*>(ID->getClassInterface());
+ llvm::Constant *Protocols =
+ EmitProtocolList(std::string("\01L_OBJC_CLASS_PROTOCOLS_") + ID->getName(),
+ Interface->protocol_begin(),
+ Interface->protocol_end());
const llvm::Type *InterfaceTy =
CGM.getTypes().ConvertType(CGM.getContext().getObjCInterfaceType(Interface));
unsigned Flags = eClassFlags_Factory;
More information about the cfe-commits
mailing list