Retain all hidden methods in the global method pool, because they may become visible...
authorDouglas Gregor <dgregor@apple.com>
Thu, 7 Feb 2013 19:13:24 +0000 (19:13 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 7 Feb 2013 19:13:24 +0000 (19:13 +0000)
llvm-svn: 174648

clang/lib/Sema/SemaDeclObjC.cpp
clang/test/Modules/Inputs/MethodPoolASub.h
clang/test/Modules/Inputs/MethodPoolBSub.h
clang/test/Modules/Inputs/module.map
clang/test/Modules/method_pool.m

index 0b09697..43b097d 100644 (file)
@@ -2045,6 +2045,10 @@ bool Sema::MatchTwoMethodDeclarations(const ObjCMethodDecl *left,
                   left->getResultType(), right->getResultType()))
     return false;
 
+  // If either is hidden, it is not considered to match.
+  if (left->isHidden() || right->isHidden())
+    return false;
+
   if (getLangOpts().ObjCAutoRefCount &&
       (left->hasAttr<NSReturnsRetainedAttr>()
          != right->hasAttr<NSReturnsRetainedAttr>() ||
index 3404ce9..0a7899d 100644 (file)
@@ -1,3 +1,4 @@
 @interface B (Sub)
 - (char *)method3;
+- (char*)method4;
 @end
index 234bfcc..499dcba 100644 (file)
@@ -116,6 +116,10 @@ module templates_right {
 module MethodPoolA {
   header "MethodPoolA.h"
 
+  explicit module Sub2 {
+    header "MethodPoolASub2.h"
+  }
+
   explicit module Sub {
     header "MethodPoolASub.h"
   }
index 1b94efb..712e55d 100644 (file)
@@ -19,6 +19,10 @@ void testMethod2(id object) {
   [object method2:1];
 } 
 
+void testMethod4(id object) {
+  [object method4]; // expected-warning{{instance method '-method4' not found (return type defaults to 'id')}}
+} 
+
 @import MethodPoolB;
 
 void testMethod1Again(id object) {
@@ -46,3 +50,7 @@ void testMethod3AgainAgain(id object) {
   // expected-note@2{{using}}
   // expected-note@2{{also found}}
 }
+
+void testMethod4Again(id object) {
+  [object method4];
+}