diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2009-03-20 19:18:21 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-03-20 19:18:21 +0000 |
commit | f469557743f77918d2ca8226e2ee2888998ffd4a (patch) | |
tree | 2fd3dff79e2563c7b9600e8f7b15f1010d60a9cb | |
parent | b82dcd827495592a8748692ce4bf80402f21b8d4 (diff) |
More super dot-syntax property implementation
when there is actually a property declaration
used in the dot-syntax.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67391 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/CGObjC.cpp | 72 | ||||
-rw-r--r-- | lib/CodeGen/CodeGenFunction.h | 2 | ||||
-rw-r--r-- | test/CodeGenObjC/super-dotsyntax-property.m | 8 | ||||
-rw-r--r-- | test/Coverage/objc-language-features.inc | 2 |
4 files changed, 56 insertions, 28 deletions
diff --git a/lib/CodeGen/CGObjC.cpp b/lib/CodeGen/CGObjC.cpp index 84d60ea7df..7f5262df1d 100644 --- a/lib/CodeGen/CGObjC.cpp +++ b/lib/CodeGen/CGObjC.cpp @@ -315,10 +315,29 @@ QualType CodeGenFunction::TypeOfSelfObject() { return PTy->getPointeeType(); } +RValue CodeGenFunction::EmitObjCSuperPropertyGet(const Expr *Exp, + const Selector &S) { + llvm::Value *Receiver = LoadObjCSelf(); + const ObjCMethodDecl *OMD = cast<ObjCMethodDecl>(CurFuncDecl); + bool isClassMessage = OMD->isClassMethod(); + bool isCategoryImpl = isa<ObjCCategoryImplDecl>(OMD->getDeclContext()); + return CGM.getObjCRuntime().GenerateMessageSendSuper(*this, + Exp->getType(), + S, + OMD->getClassInterface(), + isCategoryImpl, + Receiver, + isClassMessage, + CallArgList()); + +} + RValue CodeGenFunction::EmitObjCPropertyGet(const Expr *Exp) { // FIXME: Split it into two separate routines. if (const ObjCPropertyRefExpr *E = dyn_cast<ObjCPropertyRefExpr>(Exp)) { Selector S = E->getProperty()->getGetterName(); + if (isa<ObjCSuperExpr>(E->getBase())) + return EmitObjCSuperPropertyGet(E, S); return CGM.getObjCRuntime(). GenerateMessageSend(*this, Exp->getType(), S, EmitScalarExpr(E->getBase()), @@ -332,20 +351,8 @@ RValue CodeGenFunction::EmitObjCPropertyGet(const Expr *Exp) { const ObjCInterfaceDecl *OID = KE->getClassProp(); Receiver = CGM.getObjCRuntime().GetClass(Builder, OID); } - else if (isa<ObjCSuperExpr>(KE->getBase())) { - Receiver = LoadObjCSelf(); - const ObjCMethodDecl *OMD = cast<ObjCMethodDecl>(CurFuncDecl); - bool isClassMessage = OMD->isClassMethod(); - bool isCategoryImpl = isa<ObjCCategoryImplDecl>(OMD->getDeclContext()); - return CGM.getObjCRuntime().GenerateMessageSendSuper(*this, - KE->getType(), - S, - OMD->getClassInterface(), - isCategoryImpl, - Receiver, - isClassMessage, - CallArgList()); - } + else if (isa<ObjCSuperExpr>(KE->getBase())) + return EmitObjCSuperPropertyGet(KE, S); else Receiver = EmitScalarExpr(KE->getBase()); return CGM.getObjCRuntime(). @@ -355,11 +362,35 @@ RValue CodeGenFunction::EmitObjCPropertyGet(const Expr *Exp) { } } +void CodeGenFunction::EmitObjCSuperPropertySet(const Expr *Exp, + const Selector &S, + RValue Src) { + CallArgList Args; + llvm::Value *Receiver = LoadObjCSelf(); + const ObjCMethodDecl *OMD = cast<ObjCMethodDecl>(CurFuncDecl); + bool isClassMessage = OMD->isClassMethod(); + bool isCategoryImpl = isa<ObjCCategoryImplDecl>(OMD->getDeclContext()); + Args.push_back(std::make_pair(Src, Exp->getType())); + CGM.getObjCRuntime().GenerateMessageSendSuper(*this, + Exp->getType(), + S, + OMD->getClassInterface(), + isCategoryImpl, + Receiver, + isClassMessage, + Args); + return; +} + void CodeGenFunction::EmitObjCPropertySet(const Expr *Exp, RValue Src) { // FIXME: Split it into two separate routines. if (const ObjCPropertyRefExpr *E = dyn_cast<ObjCPropertyRefExpr>(Exp)) { Selector S = E->getProperty()->getSetterName(); + if (isa<ObjCSuperExpr>(E->getBase())) { + EmitObjCSuperPropertySet(E, S, Src); + return; + } CallArgList Args; Args.push_back(std::make_pair(Src, E->getType())); CGM.getObjCRuntime().GenerateMessageSend(*this, getContext().VoidTy, S, @@ -375,18 +406,7 @@ void CodeGenFunction::EmitObjCPropertySet(const Expr *Exp, Receiver = CGM.getObjCRuntime().GetClass(Builder, OID); } else if (isa<ObjCSuperExpr>(E->getBase())) { - Receiver = LoadObjCSelf(); - const ObjCMethodDecl *OMD = cast<ObjCMethodDecl>(CurFuncDecl); - bool isClassMessage = OMD->isClassMethod(); - bool isCategoryImpl = isa<ObjCCategoryImplDecl>(OMD->getDeclContext()); - CGM.getObjCRuntime().GenerateMessageSendSuper(*this, - E->getType(), - S, - OMD->getClassInterface(), - isCategoryImpl, - Receiver, - isClassMessage, - Args); + EmitObjCSuperPropertySet(E, S, Src); return; } else diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h index 8b578a6f39..a54e187658 100644 --- a/lib/CodeGen/CodeGenFunction.h +++ b/lib/CodeGen/CodeGenFunction.h @@ -673,7 +673,9 @@ public: llvm::Value *EmitObjCSelectorExpr(const ObjCSelectorExpr *E); RValue EmitObjCMessageExpr(const ObjCMessageExpr *E); RValue EmitObjCPropertyGet(const Expr *E); + RValue EmitObjCSuperPropertyGet(const Expr *Exp, const Selector &S); void EmitObjCPropertySet(const Expr *E, RValue Src); + void EmitObjCSuperPropertySet(const Expr *E, const Selector &S, RValue Src); //===--------------------------------------------------------------------===// diff --git a/test/CodeGenObjC/super-dotsyntax-property.m b/test/CodeGenObjC/super-dotsyntax-property.m index 8c51cfc533..cd0d5652d4 100644 --- a/test/CodeGenObjC/super-dotsyntax-property.m +++ b/test/CodeGenObjC/super-dotsyntax-property.m @@ -1,6 +1,10 @@ // RUN: clang -emit-llvm -o %t %s @interface B +{ + int _parent; +} +@property int parent; +(int) classGetter; +(void) setClassGetter:(int) arg; @@ -25,6 +29,10 @@ super.getter = 200; int x = super.getter; } +-(void) setParent : (int) arg { + super.parent = arg + super.parent; + +} @end void f0() { diff --git a/test/Coverage/objc-language-features.inc b/test/Coverage/objc-language-features.inc index 3b092ffbf4..477cbe3746 100644 --- a/test/Coverage/objc-language-features.inc +++ b/test/Coverage/objc-language-features.inc @@ -34,9 +34,7 @@ const char *s1 = __FUNCTION__; const char *s2 = __PRETTY_FUNCTION__; [super im0]; -#ifndef IRGENABLE int x = super.p0; -#endif } -(void) im1: (int) x, ... { } |