From c88a70d885cd6dbf6e8bcb4e719407662139dfab Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Tue, 3 Feb 2009 00:09:52 +0000 Subject: objc2's ir-gen for nonfragile ivar access. llvm-svn: 63578 --- clang/lib/CodeGen/CGObjC.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'clang/lib/CodeGen/CGObjC.cpp') diff --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp index 9dc45efc687..3ebee12f0df 100644 --- a/clang/lib/CodeGen/CGObjC.cpp +++ b/clang/lib/CodeGen/CGObjC.cpp @@ -194,7 +194,8 @@ void CodeGenFunction::GenerateObjCGetter(ObjCImplementationDecl *IMP, } else { FieldDecl *Field = IMP->getClassInterface()->lookupFieldDeclForIvar(getContext(), Ivar); - LValue LV = EmitLValueForIvar(LoadObjCSelf(), Ivar, Field, 0); + LValue LV = EmitLValueForIvar(TypeOfSelfObject(), + LoadObjCSelf(), Ivar, Field, 0); if (hasAggregateLLVMType(Ivar->getType())) { EmitAggregateCopy(ReturnValue, LV.getAddress(), Ivar->getType()); } @@ -294,6 +295,14 @@ llvm::Value *CodeGenFunction::LoadObjCSelf() { return Builder.CreateLoad(LocalDeclMap[OMD->getSelfDecl()], "self"); } +QualType CodeGenFunction::TypeOfSelfObject() { + const ObjCMethodDecl *OMD = cast(CurFuncDecl); + ImplicitParamDecl *selfDecl = OMD->getSelfDecl(); + const PointerType *PTy = + cast(getContext().getCanonicalType(selfDecl->getType())); + return PTy->getPointeeType(); +} + RValue CodeGenFunction::EmitObjCPropertyGet(const Expr *Exp) { // FIXME: Split it into two separate routines. if (const ObjCPropertyRefExpr *E = dyn_cast(Exp)) { -- cgit v1.2.3