diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2009-01-28 22:18:42 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-01-28 22:18:42 +0000 |
commit | 5de14dc87966ab98730cfacffe0b7d3198a91a62 (patch) | |
tree | 0a8ae2f0106172152cf53b173089a5d32b72545a /lib/CodeGen/CGObjCMac.cpp | |
parent | 679f4981e33643d3bc459b8208803ad2925cf282 (diff) |
property metadata for objc2's nonfragile abi
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63246 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGObjCMac.cpp')
-rw-r--r-- | lib/CodeGen/CGObjCMac.cpp | 45 |
1 files changed, 30 insertions, 15 deletions
diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp index 99c6c04abd..acd5315842 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -351,6 +351,13 @@ protected: const RecordDecl *GetFirstIvarInRecord(const ObjCInterfaceDecl *OID, RecordDecl::field_iterator &FIV, RecordDecl::field_iterator &PIV); + /// EmitPropertyList - Emit the given property list. The return + /// value has type PropertyListPtrTy. + llvm::Constant *EmitPropertyList(const std::string &Name, + const Decl *Container, + const ObjCContainerDecl *OCD, + const ObjCCommonTypesHelper &ObjCTypes); + public: CGObjCCommonMac(CodeGen::CodeGenModule &cgm) : CGM(cgm) { } @@ -443,12 +450,6 @@ private: const char *Section, const ConstantVector &Methods); - /// EmitPropertyList - Emit the given property list. The return - /// value has type PropertyListPtrTy. - llvm::Constant *EmitPropertyList(const std::string &Name, - const Decl *Container, - const ObjCContainerDecl *OCD); - /// GetOrEmitProtocol - Get the protocol object for the given /// declaration, emitting it if necessary. The return value has type /// ProtocolPtrTy. @@ -954,7 +955,7 @@ CGObjCMac::EmitProtocolExtension(const ObjCProtocolDecl *PD, OptClassMethods); Values[3] = EmitPropertyList("\01L_OBJC_$_PROP_PROTO_LIST_" + PD->getNameAsString(), - 0, PD); + 0, PD, ObjCTypes); // Return null if no extension bits are used. if (Values[1]->isNullValue() && Values[2]->isNullValue() && @@ -1030,9 +1031,10 @@ CGObjCMac::EmitProtocolList(const std::string &Name, struct _objc_property[prop_count]; }; */ -llvm::Constant *CGObjCMac::EmitPropertyList(const std::string &Name, - const Decl *Container, - const ObjCContainerDecl *OCD) { +llvm::Constant *CGObjCCommonMac::EmitPropertyList(const std::string &Name, + const Decl *Container, + const ObjCContainerDecl *OCD, + const ObjCCommonTypesHelper &ObjCTypes) { std::vector<llvm::Constant*> Properties, Prop(2); for (ObjCContainerDecl::prop_iterator I = OCD->prop_begin(), E = OCD->prop_end(); I != E; ++I) { @@ -1063,6 +1065,8 @@ llvm::Constant *CGObjCMac::EmitPropertyList(const std::string &Name, Init, Name, &CGM.getModule()); + if (ObjCABI == 2) + GV->setSection("__DATA, __objc_const"); // No special section on property lists? UsedGlobals.push_back(GV); return llvm::ConstantExpr::getBitCast(GV, @@ -1172,7 +1176,7 @@ void CGObjCMac::GenerateCategory(const ObjCCategoryImplDecl *OCD) { // If there is no category @interface then there can be no properties. if (Category) { Values[6] = EmitPropertyList(std::string("\01L_OBJC_$_PROP_LIST_") + ExtName, - OCD, Category); + OCD, Category, ObjCTypes); } else { Values[6] = llvm::Constant::getNullValue(ObjCTypes.PropertyListPtrTy); } @@ -1447,7 +1451,7 @@ CGObjCMac::EmitClassExtension(const ObjCImplementationDecl *ID) { // FIXME: Output weak_ivar_layout string. Values[1] = llvm::Constant::getNullValue(ObjCTypes.Int8PtrTy); Values[2] = EmitPropertyList("\01L_OBJC_$_PROP_LIST_" + ID->getNameAsString(), - ID, ID->getClassInterface()); + ID, ID->getClassInterface(), ObjCTypes); // Return null if no extension bits are used. if (Values[1]->isNullValue() && Values[2]->isNullValue()) @@ -3195,7 +3199,13 @@ llvm::GlobalVariable * CGObjCNonFragileABIMac::BuildClassRoTInitializer( else Values[ 7] = EmitIvarList(ID); Values[ 8] = llvm::Constant::getNullValue(ObjCTypes.Int8PtrTy); - Values[ 9] = llvm::Constant::getNullValue(ObjCTypes.PropertyListPtrTy); + if (flags & CLS_META) + Values[ 9] = llvm::Constant::getNullValue(ObjCTypes.PropertyListPtrTy); + else + Values[ 9] = + EmitPropertyList( + "\01l_OBJC_$_PROP_LIST_" + ID->getNameAsString(), + ID, ID->getClassInterface(), ObjCTypes); llvm::Constant *Init = llvm::ConstantStruct::get(ObjCTypes.ClassRonfABITy, Values); llvm::GlobalVariable *CLASS_RO_GV = @@ -3461,8 +3471,13 @@ void CGObjCNonFragileABIMac::GenerateCategory(const ObjCCategoryImplDecl *OCD) "__DATA, __objc_const", Methods); Values[4] = llvm::Constant::getNullValue(ObjCTypes.ProtocolListnfABIPtrTy); - Values[5] = llvm::Constant::getNullValue(ObjCTypes.PropertyListPtrTy); - + const ObjCCategoryDecl *Category = + Interface->FindCategoryDeclaration(OCD->getIdentifier()); + std::string ExtName(Interface->getNameAsString() + "_$_" + + OCD->getNameAsString()); + Values[5] = + EmitPropertyList(std::string("\01l_OBJC_$_PROP_LIST_") + ExtName, + OCD, Category, ObjCTypes); llvm::Constant *Init = llvm::ConstantStruct::get(ObjCTypes.CategorynfABITy, Values); |