mirror of
https://github.com/intel/llvm.git
synced 2026-01-26 21:53:12 +08:00
Implement ir gen. for setter/getter applied to 'super'
in a property dot-syntax notation. llvm-svn: 67382
This commit is contained in:
@@ -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,
|
||||
|
||||
33
clang/test/CodeGenObjC/super-dotsyntax-property.m
Normal file
33
clang/test/CodeGenObjC/super-dotsyntax-property.m
Normal 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];
|
||||
}
|
||||
Reference in New Issue
Block a user