[cfe-commits] r57995 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/SemaObjC/property-11.m

Steve Naroff snaroff at apple.com
Wed Oct 22 12:16:28 PDT 2008


Author: snaroff
Date: Wed Oct 22 14:16:27 2008
New Revision: 57995

URL: http://llvm.org/viewvc/llvm-project?rev=57995&view=rev
Log:
Fix <rdar://problem/6257675> error: member reference base type ('NSUserDefaults *') is not a structure or union.

Teach Sema::ActOnMemberReferenceExpr() to look through local category implementations associated with the class.


Added:
    cfe/trunk/test/SemaObjC/property-11.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=57995&r1=57994&r2=57995&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Oct 22 14:16:27 2008
@@ -977,6 +977,13 @@
               ObjCImplementations[ClassDecl->getIdentifier()])
             Getter = ImpDecl->getInstanceMethod(Sel);
 
+    // Look through local category implementations associated with the class.
+    if (!Getter) {
+      for (unsigned i = 0; i < ObjCCategoryImpls.size() && !Getter; i++) {
+        if (ObjCCategoryImpls[i]->getClassInterface() == IFace)
+          Getter = ObjCCategoryImpls[i]->getInstanceMethod(Sel);
+      }
+    }
     if (Getter) {
       // If we found a getter then this may be a valid dot-reference, we
       // need to also look for the matching setter.

Added: cfe/trunk/test/SemaObjC/property-11.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/property-11.m?rev=57995&view=auto

==============================================================================
--- cfe/trunk/test/SemaObjC/property-11.m (added)
+++ cfe/trunk/test/SemaObjC/property-11.m Wed Oct 22 14:16:27 2008
@@ -0,0 +1,32 @@
+// RUN: clang -fsyntax-only -verify %s
+
+ at interface NSSound
+ at end
+ at interface NSFont
+ at end
+
+ at interface NSSound (Adds)
+ at end
+
+ at implementation NSSound (Adds)
+- foo {
+  return self;
+}
+- (void)setFoo:obj {
+}
+ at end
+
+ at implementation NSFont (Adds)
+
+- xx {
+  NSSound *x;
+  id o;
+
+  o = [x foo]; 
+  o = x.foo;
+  [x setFoo:o];
+  x.foo = o;
+}
+
+ at end
+





More information about the cfe-commits mailing list