Fix objc type conversion issues with the GNU runtime, patch by

David Chisnall

llvm-svn: 62703
This commit is contained in:
Chris Lattner 2009-01-21 18:52:19 +00:00
parent d00bca3572
commit d1760b7837
1 changed files with 11 additions and 7 deletions

View File

@ -40,8 +40,8 @@ class CGObjCGNU : public CodeGen::CGObjCRuntime {
private:
CodeGen::CodeGenModule &CGM;
llvm::Module &TheModule;
const llvm::StructType *SelStructTy;
const llvm::Type *SelectorTy;
const llvm::PointerType *SelectorTy;
const llvm::Type *ExpectedSelTy;
const llvm::Type *PtrToInt8Ty;
const llvm::Type *IMPTy;
const llvm::Type *IdTy;
@ -168,11 +168,12 @@ CGObjCGNU::CGObjCGNU(CodeGen::CodeGenModule &cgm)
PtrToInt8Ty =
llvm::PointerType::getUnqual(llvm::Type::Int8Ty);
// Get the selector Type.
SelStructTy = llvm::StructType::get(
PtrToInt8Ty,
PtrToInt8Ty,
NULL);
SelectorTy = llvm::PointerType::getUnqual(SelStructTy);
SelectorTy = cast<llvm::PointerType>(
CGM.getTypes().ConvertType(CGM.getContext().getObjCSelType()));
ExpectedSelTy =
CGM.getTypes().ConvertType(CGM.getContext().getObjCSelType());
PtrToIntTy = llvm::PointerType::getUnqual(IntTy);
PtrTy = PtrToInt8Ty;
@ -797,6 +798,9 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() {
UntypedSelectors.empty())
return NULL;
const llvm::StructType *SelStructTy =
cast<llvm::StructType>(SelectorTy->getTypeAtIndex(0U));
// Name the ObjC types to make the IR a bit easier to read
TheModule.addTypeName(".objc_selector", SelectorTy);
TheModule.addTypeName(".objc_id", IdTy);