summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2009-03-20 17:22:23 +0000
committerFariborz Jahanian <fjahanian@apple.com>2009-03-20 17:22:23 +0000
commit150abf2a00362f13525e2e5929dd40bfcd5dfa13 (patch)
treef7caf2a1e78d632bd36abffca6a244e2ec6315f4
parent88c347443e1ccfad821698b00275681ba5062148 (diff)
downloadbcm5719-llvm-150abf2a00362f13525e2e5929dd40bfcd5dfa13.tar.gz
bcm5719-llvm-150abf2a00362f13525e2e5929dd40bfcd5dfa13.zip
Implement ir gen. for setter/getter applied to 'super'
in a property dot-syntax notation. llvm-svn: 67382
-rw-r--r--clang/lib/CodeGen/CGObjC.cpp31
-rw-r--r--clang/test/CodeGenObjC/super-dotsyntax-property.m33
2 files changed, 63 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp
index aa1f4c24944..84d60ea7df9 100644
--- a/clang/lib/CodeGen/CGObjC.cpp
+++ b/clang/lib/CodeGen/CGObjC.cpp
@@ -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,
diff --git a/clang/test/CodeGenObjC/super-dotsyntax-property.m b/clang/test/CodeGenObjC/super-dotsyntax-property.m
new file mode 100644
index 00000000000..8c51cfc5336
--- /dev/null
+++ b/clang/test/CodeGenObjC/super-dotsyntax-property.m
@@ -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];
+}
OpenPOWER on IntegriCloud