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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57995 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 9292017..5619eca 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -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.