]> granicus.if.org Git - clang/commitdiff
Patch to allow a getter call using property dot-syntax notation.
authorFariborz Jahanian <fjahanian@apple.com>
Wed, 10 Dec 2008 00:21:50 +0000 (00:21 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Wed, 10 Dec 2008 00:21:50 +0000 (00:21 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60816 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/CodeGenObjC/property-getter-dot-syntax.m [new file with mode: 0644]

index cdca6827049074ba78f9c3ffea5f8f35923a226b..a2dc7f7c891367f89a4b84b45dd1d95a1a0e4fe2 100644 (file)
@@ -1309,9 +1309,16 @@ ActOnMemberReferenceExpr(ExprTy *Base, SourceLocation OpLoc,
   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) {
diff --git a/test/CodeGenObjC/property-getter-dot-syntax.m b/test/CodeGenObjC/property-getter-dot-syntax.m
new file mode 100644 (file)
index 0000000..962862b
--- /dev/null
@@ -0,0 +1,11 @@
+// RUN: clang -fnext-runtime --emit-llvm -o %t %s
+
+@protocol NSObject
+- (void *)description;
+@end
+
+int main()
+{
+        id<NSObject> eggs;
+        void *eggsText= eggs.description;
+}