[cfe-commits] r60816 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/CodeGenObjC/property-getter-dot-syntax.m

Fariborz Jahanian fjahanian at apple.com
Tue Dec 9 16:21:51 PST 2008


Author: fjahanian
Date: Tue Dec  9 18:21:50 2008
New Revision: 60816

URL: http://llvm.org/viewvc/llvm-project?rev=60816&view=rev
Log:
Patch to allow a getter call using property dot-syntax notation.

Added:
    cfe/trunk/test/CodeGenObjC/property-getter-dot-syntax.m
Modified:
    cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=60816&r1=60815&r2=60816&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Dec  9 18:21:50 2008
@@ -1309,9 +1309,16 @@
   if (OpKind == tok::period && (QIdTy = BaseType->getAsObjCQualifiedIdType())) {
     // Check protocols on qualified interfaces.
     for (ObjCQualifiedIdType::qual_iterator I = QIdTy->qual_begin(),
-         E = QIdTy->qual_end(); I != E; ++I)
+         E = QIdTy->qual_end(); I != E; ++I) {
       if (ObjCPropertyDecl *PD = (*I)->FindPropertyDeclaration(&Member))
         return new ObjCPropertyRefExpr(PD, PD->getType(), MemberLoc, BaseExpr);
+      // Also must look for a getter name which uses property syntax.
+      Selector Sel = PP.getSelectorTable().getNullarySelector(&Member);
+      if (ObjCMethodDecl *OMD = (*I)->getInstanceMethod(Sel)) {
+        return new ObjCMessageExpr(BaseExpr, Sel, OMD->getResultType(), OMD, 
+                                   OpLoc, MemberLoc, NULL, 0);
+      }
+    }
   }  
   // Handle 'field access' to vectors, such as 'V.xx'.
   if (BaseType->isExtVectorType() && OpKind == tok::period) {

Added: cfe/trunk/test/CodeGenObjC/property-getter-dot-syntax.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/property-getter-dot-syntax.m?rev=60816&view=auto

==============================================================================
--- cfe/trunk/test/CodeGenObjC/property-getter-dot-syntax.m (added)
+++ cfe/trunk/test/CodeGenObjC/property-getter-dot-syntax.m Tue Dec  9 18:21:50 2008
@@ -0,0 +1,11 @@
+// RUN: clang -fnext-runtime --emit-llvm -o %t %s
+
+ at protocol NSObject
+- (void *)description;
+ at end
+
+int main()
+{
+        id<NSObject> eggs;
+        void *eggsText= eggs.description;
+}





More information about the cfe-commits mailing list