[cfe-commits] r67382 - in /cfe/trunk: lib/CodeGen/CGObjC.cpp test/CodeGenObjC/super-dotsyntax-property.m

Fariborz Jahanian fjahanian at apple.com
Fri Mar 20 10:22:25 PDT 2009


Author: fjahanian
Date: Fri Mar 20 12:22:23 2009
New Revision: 67382

URL: http://llvm.org/viewvc/llvm-project?rev=67382&view=rev
Log:
Implement ir gen. for setter/getter applied to 'super' 
in a property dot-syntax notation.

Added:
    cfe/trunk/test/CodeGenObjC/super-dotsyntax-property.m
Modified:
    cfe/trunk/lib/CodeGen/CGObjC.cpp

Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=67382&r1=67381&r2=67382&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Fri Mar 20 12:22:23 2009
@@ -332,6 +332,20 @@
       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 @@
       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, 

Added: cfe/trunk/test/CodeGenObjC/super-dotsyntax-property.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/super-dotsyntax-property.m?rev=67382&view=auto

==============================================================================
--- cfe/trunk/test/CodeGenObjC/super-dotsyntax-property.m (added)
+++ cfe/trunk/test/CodeGenObjC/super-dotsyntax-property.m Fri Mar 20 12:22:23 2009
@@ -0,0 +1,33 @@
+// RUN: clang -emit-llvm -o %t %s
+
+ at interface B
+  +(int) classGetter;
+  +(void) setClassGetter:(int) arg;
+
+  -(int) getter;
+  -(void) setGetter:(int)arg;
+ at end
+
+ at interface A : B
+ at end
+
+ at implementation A
++(int) classGetter {
+  return 0;
+}
+
++(int) classGetter2 {
+  super.classGetter = 100;
+  return super.classGetter;
+}
+
+-(void) method {
+  super.getter = 200;
+  int x = super.getter;
+}
+ at end
+
+void f0() {
+  int l1 = A.classGetter;
+  int l2 = [A classGetter2];
+}





More information about the cfe-commits mailing list