Implement ir gen. for setter/getter applied to 'super'

in a property dot-syntax notation.

llvm-svn: 67382
This commit is contained in:
Fariborz Jahanian
2009-03-20 17:22:23 +00:00
parent 88c347443e
commit 150abf2a00
2 changed files with 63 additions and 1 deletions

View File

@@ -332,6 +332,20 @@ 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
Receiver = EmitScalarExpr(KE->getBase());
return CGM.getObjCRuntime().
@@ -360,7 +374,22 @@ void CodeGenFunction::EmitObjCPropertySet(const Expr *Exp,
const ObjCInterfaceDecl *OID = E->getClassProp();
Receiver = CGM.getObjCRuntime().GetClass(Builder, OID);
}
else
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);
return;
}
else
Receiver = EmitScalarExpr(E->getBase());
Args.push_back(std::make_pair(Src, E->getType()));
CGM.getObjCRuntime().GenerateMessageSend(*this, getContext().VoidTy, S,

View File

@@ -0,0 +1,33 @@
// RUN: clang -emit-llvm -o %t %s
@interface B
+(int) classGetter;
+(void) setClassGetter:(int) arg;
-(int) getter;
-(void) setGetter:(int)arg;
@end
@interface A : B
@end
@implementation A
+(int) classGetter {
return 0;
}
+(int) classGetter2 {
super.classGetter = 100;
return super.classGetter;
}
-(void) method {
super.getter = 200;
int x = super.getter;
}
@end
void f0() {
int l1 = A.classGetter;
int l2 = [A classGetter2];
}