Author: arphaman
Date: Wed Feb 22 17:18:49 2017
New Revision: 295903

URL: http://llvm.org/viewvc/llvm-project?rev=295903&view=rev
Log:
[ObjC][Modules] Don't perform property lookup in hidden class extensions

rdar://30603803

Modified:
    cfe/trunk/lib/AST/DeclObjC.cpp
    cfe/trunk/test/Modules/Inputs/category_right_sub.h
    cfe/trunk/test/Modules/objc-categories.m

Modified: cfe/trunk/lib/AST/DeclObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=295903&r1=295902&r2=295903&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclObjC.cpp (original)
+++ cfe/trunk/lib/AST/DeclObjC.cpp Wed Feb 22 17:18:49 2017
@@ -162,10 +162,10 @@ ObjCPropertyDecl::findPropertyDecl(const
         return nullptr;
   }
 
-  // If context is class, then lookup property in its extensions.
+  // If context is class, then lookup property in its visible extensions.
   // This comes before property is looked up in primary class.
   if (auto *IDecl = dyn_cast<ObjCInterfaceDecl>(DC)) {
-    for (const auto *Ext : IDecl->known_extensions())
+    for (const auto *Ext : IDecl->visible_extensions())
       if (ObjCPropertyDecl *PD = ObjCPropertyDecl::findPropertyDecl(Ext,
                                                        propertyID,
                                                        queryKind))

Modified: cfe/trunk/test/Modules/Inputs/category_right_sub.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/category_right_sub.h?rev=295903&r1=295902&r2=295903&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/category_right_sub.h (original)
+++ cfe/trunk/test/Modules/Inputs/category_right_sub.h Wed Feb 22 17:18:49 2017
@@ -15,3 +15,8 @@
 
 @interface Foo(LeftP4) <P4>
 @end
+
+// A hidden extension
+@interface Foo ()
+@property (assign) int hiddenPropertyFromExtension;
+@end

Modified: cfe/trunk/test/Modules/objc-categories.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/objc-categories.m?rev=295903&r1=295902&r2=295903&view=diff
==============================================================================
--- cfe/trunk/test/Modules/objc-categories.m (original)
+++ cfe/trunk/test/Modules/objc-categories.m Wed Feb 22 17:18:49 2017
@@ -53,6 +53,9 @@ void test_hidden_all_errors(Foo *foo) {
   p3p = foo.p3_prop; // expected-error{{property 'p3_prop' not found on object 
of type 'Foo *'}}
   id p4p = p4.p4_prop; // expected-error{{property 'p4_prop' not found on 
object of type 'id<P4>'}}
   p4p = foo.p4_prop; // expected-error{{property 'p4_prop' not found on object 
of type 'Foo *'}}
+
+  if (foo.hiddenPropertyFromExtension) { // expected-error {{property 
'hiddenPropertyFromExtension' not found on object of type 'Foo *'}}
+  }
 }
 
 @import category_left.sub;
@@ -74,6 +77,7 @@ void test_hidden_right_errors(Foo *foo)
   id p4p = p4.p4_prop; // expected-error{{property 'p4_prop' not found on 
object of type 'id<P4>'}}
   p4p = foo.p4_prop; // expected-error{{property 'p4_prop' not found on object 
of type 'Foo *'; did you mean 'p3_prop'?}}
   // expected-note@Inputs/category_left_sub.h:7{{'p3_prop' declared here}}
+  int hiddenFromExtension = foo.hiddenPropertyFromExtension; // expected-error 
{{property 'hiddenPropertyFromExtension' not found on object of type 'Foo *'}}
 }
 
 @import category_right.sub;
@@ -92,4 +96,6 @@ void test_hidden_okay(Foo *foo) {
   p3p = foo.p3_prop;
   id p4p = p4.p4_prop;
   p4p = foo.p4_prop;
+  if (foo.hiddenPropertyFromExtension) {
+  }
 }


_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to