diff options
author | Chris Lattner <sabre@nondot.org> | 2009-05-08 15:39:58 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-05-08 15:39:58 +0000 |
commit | a02cb80f99452a06178b5fd3d5bf64f9e748484f (patch) | |
tree | e9786df16e86aec42049183121ce6dfae53a6d70 /clang/lib/CodeGen | |
parent | 5b9241b2a6a4a2671cb31837eddbed8c284c2b07 (diff) | |
download | bcm5719-llvm-a02cb80f99452a06178b5fd3d5bf64f9e748484f.tar.gz bcm5719-llvm-a02cb80f99452a06178b5fd3d5bf64f9e748484f.zip |
"This patch fixes message sends to super in categories for the GNU runtime. This used to work, but I broke it when I modified the code to emit the same thing as GCC for message sends to super in classes."
Patch by David Chisnall!
llvm-svn: 71220
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r-- | clang/lib/CodeGen/CGObjCGNU.cpp | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp index 32e8430782a..2a2c1ab6ae0 100644 --- a/clang/lib/CodeGen/CGObjCGNU.cpp +++ b/clang/lib/CodeGen/CGObjCGNU.cpp @@ -329,27 +329,41 @@ CGObjCGNU::GenerateMessageSendSuper(CodeGen::CodeGenFunction &CGF, const CGFunctionInfo &FnInfo = Types.getFunctionInfo(ResultType, ActualArgs); const llvm::FunctionType *impType = Types.GetFunctionType(FnInfo, false); - - // Set up global aliases for the metaclass or class pointer if they do not - // already exist. These will are forward-references which will be set to - // pointers to the class and metaclass structure created for the runtime load - // function. To send a message to super, we look up the value of the - // super_class pointer from either the class or metaclass structure. llvm::Value *ReceiverClass = 0; - if (IsClassMessage) { - if (!MetaClassPtrAlias) { - MetaClassPtrAlias = new llvm::GlobalAlias(IdTy, - llvm::GlobalValue::InternalLinkage, ".objc_metaclass_ref" + - Class->getNameAsString(), NULL, &TheModule); + if (isCategoryImpl) { + llvm::Constant *classLookupFunction = 0; + std::vector<const llvm::Type*> Params; + Params.push_back(PtrTy); + if (IsClassMessage) { + classLookupFunction = CGM.CreateRuntimeFunction(llvm::FunctionType::get( + IdTy, Params, true), "objc_get_meta_class"); + } else { + classLookupFunction = CGM.CreateRuntimeFunction(llvm::FunctionType::get( + IdTy, Params, true), "objc_get_class"); } - ReceiverClass = MetaClassPtrAlias; + ReceiverClass = CGF.Builder.CreateCall(classLookupFunction, + MakeConstantString(Class->getNameAsString())); } else { - if (!ClassPtrAlias) { - ClassPtrAlias = new llvm::GlobalAlias(IdTy, - llvm::GlobalValue::InternalLinkage, ".objc_class_ref" + - Class->getNameAsString(), NULL, &TheModule); + // Set up global aliases for the metaclass or class pointer if they do not + // already exist. These will are forward-references which will be set to + // pointers to the class and metaclass structure created for the runtime load + // function. To send a message to super, we look up the value of the + // super_class pointer from either the class or metaclass structure. + if (IsClassMessage) { + if (!MetaClassPtrAlias) { + MetaClassPtrAlias = new llvm::GlobalAlias(IdTy, + llvm::GlobalValue::InternalLinkage, ".objc_metaclass_ref" + + Class->getNameAsString(), NULL, &TheModule); + } + ReceiverClass = MetaClassPtrAlias; + } else { + if (!ClassPtrAlias) { + ClassPtrAlias = new llvm::GlobalAlias(IdTy, + llvm::GlobalValue::InternalLinkage, ".objc_class_ref" + + Class->getNameAsString(), NULL, &TheModule); + } + ReceiverClass = ClassPtrAlias; } - ReceiverClass = ClassPtrAlias; } // Cast the pointer to a simplified version of the class structure ReceiverClass = CGF.Builder.CreateBitCast(ReceiverClass, |