[cfe-commits] r67391 - in /cfe/trunk: lib/CodeGen/CGObjC.cpp lib/CodeGen/CodeGenFunction.h test/CodeGenObjC/super-dotsyntax-property.m test/Coverage/objc-language-features.inc
Fariborz Jahanian
fjahanian at apple.com
Fri Mar 20 12:18:25 PDT 2009
Author: fjahanian
Date: Fri Mar 20 14:18:21 2009
New Revision: 67391
URL: http://llvm.org/viewvc/llvm-project?rev=67391&view=rev
Log:
More super dot-syntax property implementation
when there is actually a property declaration
used in the dot-syntax.
Modified:
cfe/trunk/lib/CodeGen/CGObjC.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/test/CodeGenObjC/super-dotsyntax-property.m
cfe/trunk/test/Coverage/objc-language-features.inc
Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=67391&r1=67390&r2=67391&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Fri Mar 20 14:18:21 2009
@@ -315,10 +315,29 @@
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 @@
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 @@
}
}
+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 @@
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
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=67391&r1=67390&r2=67391&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Fri Mar 20 14:18:21 2009
@@ -673,7 +673,9 @@
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);
//===--------------------------------------------------------------------===//
Modified: cfe/trunk/test/CodeGenObjC/super-dotsyntax-property.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/super-dotsyntax-property.m?rev=67391&r1=67390&r2=67391&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/super-dotsyntax-property.m (original)
+++ cfe/trunk/test/CodeGenObjC/super-dotsyntax-property.m Fri Mar 20 14:18:21 2009
@@ -1,6 +1,10 @@
// RUN: clang -emit-llvm -o %t %s
@interface B
+{
+ int _parent;
+}
+ at 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() {
Modified: cfe/trunk/test/Coverage/objc-language-features.inc
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Coverage/objc-language-features.inc?rev=67391&r1=67390&r2=67391&view=diff
==============================================================================
--- cfe/trunk/test/Coverage/objc-language-features.inc (original)
+++ cfe/trunk/test/Coverage/objc-language-features.inc Fri Mar 20 14:18:21 2009
@@ -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, ... {
}
More information about the cfe-commits
mailing list