[cfe-commits] r53845 - in /cfe/trunk: lib/Sema/SemaExpr.cpp lib/Sema/SemaExprObjC.cpp test/Sema/objc-property-9-impl-method.m

Chris Lattner sabre at nondot.org
Sun Jul 20 23:44:27 PDT 2008


Author: lattner
Date: Mon Jul 21 01:44:27 2008
New Revision: 53845

URL: http://llvm.org/viewvc/llvm-project?rev=53845&view=rev
Log:
when in the context of an @implementation, look for private methods in the
@implementation to resolve nullary selector references.

Added:
    cfe/trunk/test/Sema/objc-property-9-impl-method.m
Modified:
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/lib/Sema/SemaExprObjC.cpp

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Jul 21 01:44:27 2008
@@ -635,14 +635,26 @@
       (IFTy = PTy->getPointeeType()->getAsObjCInterfaceType())) {
     ObjCInterfaceDecl *IFace = IFTy->getDecl();
     
+    // FIXME: The logic for looking up nullary and unary selectors should be
+    // shared with the code in ActOnInstanceMessage.
+    
     // Before we look for explicit property declarations, we check for
     // nullary methods (which allow '.' notation).
     Selector Sel = PP.getSelectorTable().getNullarySelector(&Member);
-    
     if (ObjCMethodDecl *MD = IFace->lookupInstanceMethod(Sel))
       return new ObjCPropertyRefExpr(MD, MD->getResultType(), 
                                      MemberLoc, BaseExpr);
     
+    // If this reference is in an @implementation, check for 'private' methods.
+    if (ObjCMethodDecl *CurMeth = getCurMethodDecl()) {
+      if (ObjCInterfaceDecl *ClassDecl = CurMeth->getClassInterface())
+        if (ObjCImplementationDecl *ImpDecl = 
+              ObjCImplementations[ClassDecl->getIdentifier()])
+          if (ObjCMethodDecl *MD = ImpDecl->getInstanceMethod(Sel))
+            return new ObjCPropertyRefExpr(MD, MD->getResultType(), 
+                                           MemberLoc, BaseExpr);
+    }      
+    
     // FIXME: Need to deal with setter methods that take 1 argument. E.g.:
     // @interface NSBundle : NSObject {}
     // - (NSString *)bundlePath;

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Mon Jul 21 01:44:27 2008
@@ -251,10 +251,9 @@
   // Handle messages to Class.
   if (receiverType == Context.getObjCClassType().getCanonicalType()) {
     ObjCMethodDecl *Method = 0;
-    if (getCurMethodDecl()) {
-      ObjCInterfaceDecl* ClassDecl = getCurMethodDecl()->getClassInterface();
+    if (ObjCMethodDecl *CurMeth = getCurMethodDecl()) {
       // If we have an implementation in scope, check "private" methods.
-      if (ClassDecl)
+      if (ObjCInterfaceDecl *ClassDecl = CurMeth->getClassInterface())
         if (ObjCImplementationDecl *ImpDecl = 
               ObjCImplementations[ClassDecl->getIdentifier()])
           Method = ImpDecl->getClassMethod(Sel);

Added: cfe/trunk/test/Sema/objc-property-9-impl-method.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/objc-property-9-impl-method.m?rev=53845&view=auto

==============================================================================
--- cfe/trunk/test/Sema/objc-property-9-impl-method.m (added)
+++ cfe/trunk/test/Sema/objc-property-9-impl-method.m Mon Jul 21 01:44:27 2008
@@ -0,0 +1,63 @@
+// RUN: clang %s -fsyntax-only -verify
+// rdar://5967199
+
+typedef signed char BOOL;
+ at class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+
+ at protocol NSObject
+- (BOOL) isEqual:(id) object;
+ at end
+
+ at protocol NSCoding
+- (void) encodeWithCoder:(NSCoder *) aCoder;
+ at end
+
+ at interface NSObject < NSObject > {}
+ at end
+
+typedef float CGFloat;
+typedef struct _NSPoint {} NSSize;
+typedef struct _NSRect {} NSRect;
+typedef enum { NSMinXEdge = 0, NSMinYEdge = 1, NSMaxXEdge = 2, NSMaxYEdge = 3} NSRectEdge;
+extern void NSDivideRect(NSRect inRect, NSRect * slice, NSRect * rem, CGFloat amount, NSRectEdge edge);
+
+ at interface NSResponder:NSObject < NSCoding > {}
+ at end
+
+ at protocol NSAnimatablePropertyContainer
+- (id) animator;
+ at end
+
+extern NSString *NSAnimationTriggerOrderIn;
+
+ at interface NSView:NSResponder < NSAnimatablePropertyContainer > {}
+-(NSRect) bounds;
+ at end
+
+enum {
+  NSBackgroundStyleLight = 0, NSBackgroundStyleDark, NSBackgroundStyleRaised, NSBackgroundStyleLowered
+};
+
+ at interface NSTabView:NSView {}
+ at end
+
+@ class OrganizerTabHeader;
+
+ at interface OrganizerTabView:NSTabView {}
+ at property(assign)
+NSSize minimumSize;
+ at end
+
+ at interface OrganizerTabView()
+ at property(readonly) OrganizerTabHeader *tabHeaderView;
+ at property(readonly) NSRect headerRect;
+ at end
+
+ at implementation OrganizerTabView
+ at dynamic tabHeaderView, headerRect, minimumSize;
+-(CGFloat) tabAreaThickness {}
+-(NSRectEdge) rectEdgeForTabs { 
+  NSRect dummy, result = {};
+  NSDivideRect(self.bounds, &result, &dummy, self.tabAreaThickness, self.rectEdgeForTabs);
+}
+





More information about the cfe-commits mailing list