]> granicus.if.org Git - clang/commitdiff
when in the context of an @implementation, look for private methods in the
authorChris Lattner <sabre@nondot.org>
Mon, 21 Jul 2008 06:44:27 +0000 (06:44 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 21 Jul 2008 06:44:27 +0000 (06:44 +0000)
@implementation to resolve nullary selector references.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53845 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
lib/Sema/SemaExprObjC.cpp
test/Sema/objc-property-9-impl-method.m [new file with mode: 0644]

index 9cb8b98f7043f65a38ab512c3cfaeaa3cac666dd..4f085d2e43710f0e7a7fd31538a40cdba1695dd4 100644 (file)
@@ -635,14 +635,26 @@ ActOnMemberReferenceExpr(ExprTy *Base, SourceLocation OpLoc,
       (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;
index 99a7afdc1af3250e7a29b1f34dbe8d0eb36f6944..56a1f812b15bcae14720e501b448b40f703f3b45 100644 (file)
@@ -251,10 +251,9 @@ Sema::ExprResult Sema::ActOnInstanceMessage(ExprTy *receiver, Selector Sel,
   // 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);
diff --git a/test/Sema/objc-property-9-impl-method.m b/test/Sema/objc-property-9-impl-method.m
new file mode 100644 (file)
index 0000000..bb13d01
--- /dev/null
@@ -0,0 +1,63 @@
+// RUN: clang %s -fsyntax-only -verify
+// rdar://5967199
+
+typedef signed char BOOL;
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+
+@protocol NSObject
+- (BOOL) isEqual:(id) object;
+@end
+
+@protocol NSCoding
+- (void) encodeWithCoder:(NSCoder *) aCoder;
+@end
+
+@interface NSObject < NSObject > {}
+@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);
+
+@interface NSResponder:NSObject < NSCoding > {}
+@end
+
+@protocol NSAnimatablePropertyContainer
+- (id) animator;
+@end
+
+extern NSString *NSAnimationTriggerOrderIn;
+
+@interface NSView:NSResponder < NSAnimatablePropertyContainer > {}
+-(NSRect) bounds;
+@end
+
+enum {
+  NSBackgroundStyleLight = 0, NSBackgroundStyleDark, NSBackgroundStyleRaised, NSBackgroundStyleLowered
+};
+
+@interface NSTabView:NSView {}
+@end
+
+@ class OrganizerTabHeader;
+
+@interface OrganizerTabView:NSTabView {}
+@property(assign)
+NSSize minimumSize;
+@end
+
+@interface OrganizerTabView()
+@property(readonly) OrganizerTabHeader *tabHeaderView;
+@property(readonly) NSRect headerRect;
+@end
+
+@implementation OrganizerTabView
+@dynamic tabHeaderView, headerRect, minimumSize;
+-(CGFloat) tabAreaThickness {}
+-(NSRectEdge) rectEdgeForTabs { 
+  NSRect dummy, result = {};
+  NSDivideRect(self.bounds, &result, &dummy, self.tabAreaThickness, self.rectEdgeForTabs);
+}
+