diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2009-01-30 00:46:37 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-01-30 00:46:37 +0000 |
commit | 3819a0bf47f43fc6e496c1d0257a1658424ab6a5 (patch) | |
tree | 453f78595452d8fa3b50d92140afec4a6cdf0ddf /lib/CodeGen/CGObjCMac.cpp | |
parent | 6949ce44f8973678319ada99080f623ad0547e09 (diff) |
Bug fixing involving method-list in protocol meta-data
(objc2 nonfragile-abi).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63351 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGObjCMac.cpp')
-rw-r--r-- | lib/CodeGen/CGObjCMac.cpp | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp index 3f3ea9e220..526a95a963 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -572,6 +572,8 @@ private: llvm::Constant *GetMethodConstant(const ObjCMethodDecl *MD); + llvm::Constant *GetMethodDescriptionConstant(const ObjCMethodDecl *MD); + /// EmitMethodList - Emit the method list for the given /// implementation. The return value has type MethodListnfABITy. llvm::Constant *EmitMethodList(const std::string &Name, @@ -3789,7 +3791,7 @@ llvm::Constant *CGObjCNonFragileABIMac::GetOrEmitProtocol( for (ObjCProtocolDecl::instmeth_iterator i = PD->instmeth_begin(), e = PD->instmeth_end(); i != e; ++i) { ObjCMethodDecl *MD = *i; - llvm::Constant *C = GetMethodConstant(MD); + llvm::Constant *C = GetMethodDescriptionConstant(MD); if (MD->getImplementationControl() == ObjCMethodDecl::Optional) { OptInstanceMethods.push_back(C); } else { @@ -3800,7 +3802,7 @@ llvm::Constant *CGObjCNonFragileABIMac::GetOrEmitProtocol( for (ObjCProtocolDecl::classmeth_iterator i = PD->classmeth_begin(), e = PD->classmeth_end(); i != e; ++i) { ObjCMethodDecl *MD = *i; - llvm::Constant *C = GetMethodConstant(MD); + llvm::Constant *C = GetMethodDescriptionConstant(MD); if (MD->getImplementationControl() == ObjCMethodDecl::Optional) { OptClassMethods.push_back(C); } else { @@ -3817,19 +3819,19 @@ llvm::Constant *CGObjCNonFragileABIMac::GetOrEmitProtocol( PD->protocol_begin(), PD->protocol_end()); - Values[3] = EmitMethodList("\01l_OBJC_$_INSTANCE_METHODS_" + Values[3] = EmitMethodList("\01l_OBJC_$_PROTOCOL_INSTANCE_METHODS_" + PD->getNameAsString(), "__DATA, __objc_const", InstanceMethods); - Values[4] = EmitMethodList("\01l_OBJC_$_CLASS_METHODS_" + Values[4] = EmitMethodList("\01l_OBJC_$_PROTOCOL_CLASS_METHODS_" + PD->getNameAsString(), "__DATA, __objc_const", ClassMethods); - Values[5] = EmitMethodList("\01l_OBJC_$_INSTANCE_METHODS_OPT_" + Values[5] = EmitMethodList("\01l_OBJC_$_PROTOCOL_INSTANCE_METHODS_OPT_" + PD->getNameAsString(), "__DATA, __objc_const", OptInstanceMethods); - Values[6] = EmitMethodList("\01l_OBJC_$_CLASS_METHODS_OPT_" + Values[6] = EmitMethodList("\01l_OBJC_$_PROTOCOL_CLASS_METHODS_OPT_" + PD->getNameAsString(), "__DATA, __objc_const", OptClassMethods); @@ -3921,6 +3923,23 @@ CGObjCNonFragileABIMac::EmitProtocolList(const std::string &Name, return llvm::ConstantExpr::getBitCast(GV, ObjCTypes.ProtocolListnfABIPtrTy); } +/// GetMethodDescriptionConstant - This routine build following meta-data: +/// struct _objc_method { +/// SEL _cmd; +/// char *method_type; +/// char *_imp; +/// } + +llvm::Constant * +CGObjCNonFragileABIMac::GetMethodDescriptionConstant(const ObjCMethodDecl *MD) { + std::vector<llvm::Constant*> Desc(3); + Desc[0] = llvm::ConstantExpr::getBitCast(GetMethodVarName(MD->getSelector()), + ObjCTypes.SelectorPtrTy); + Desc[1] = GetMethodVarType(MD); + // FIXME. This is really always NULL? + Desc[2] = llvm::Constant::getNullValue(ObjCTypes.Int8PtrTy); + return llvm::ConstantStruct::get(ObjCTypes.MethodTy, Desc); +} /* *** */ CodeGen::CGObjCRuntime * |