r174648 - Retain all hidden methods in the global method pool, because they may become visible <rdar://problem/13172858>.

Douglas Gregor dgregor at apple.com
Thu Feb 7 11:13:24 PST 2013


Author: dgregor
Date: Thu Feb  7 13:13:24 2013
New Revision: 174648

URL: http://llvm.org/viewvc/llvm-project?rev=174648&view=rev
Log:
Retain all hidden methods in the global method pool, because they may become visible <rdar://problem/13172858>.

Modified:
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp
    cfe/trunk/test/Modules/Inputs/MethodPoolASub.h
    cfe/trunk/test/Modules/Inputs/MethodPoolBSub.h
    cfe/trunk/test/Modules/Inputs/module.map
    cfe/trunk/test/Modules/method_pool.m

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=174648&r1=174647&r2=174648&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Thu Feb  7 13:13:24 2013
@@ -2045,6 +2045,10 @@ bool Sema::MatchTwoMethodDeclarations(co
                   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>() ||

Modified: cfe/trunk/test/Modules/Inputs/MethodPoolASub.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/MethodPoolASub.h?rev=174648&r1=174647&r2=174648&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/MethodPoolASub.h (original)
+++ cfe/trunk/test/Modules/Inputs/MethodPoolASub.h Thu Feb  7 13:13:24 2013
@@ -1,3 +1,4 @@
 @interface A (Sub)
 - (char)method3;
+- (char*)method4;
 @end

Modified: cfe/trunk/test/Modules/Inputs/MethodPoolBSub.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/MethodPoolBSub.h?rev=174648&r1=174647&r2=174648&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/MethodPoolBSub.h (original)
+++ cfe/trunk/test/Modules/Inputs/MethodPoolBSub.h Thu Feb  7 13:13:24 2013
@@ -1,3 +1,4 @@
 @interface B (Sub)
 - (char *)method3;
+- (char*)method4;
 @end

Modified: cfe/trunk/test/Modules/Inputs/module.map
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/module.map?rev=174648&r1=174647&r2=174648&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/module.map (original)
+++ cfe/trunk/test/Modules/Inputs/module.map Thu Feb  7 13:13:24 2013
@@ -116,6 +116,10 @@ module templates_right {
 module MethodPoolA {
   header "MethodPoolA.h"
 
+  explicit module Sub2 {
+    header "MethodPoolASub2.h"
+  }
+
   explicit module Sub {
     header "MethodPoolASub.h"
   }

Modified: cfe/trunk/test/Modules/method_pool.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/method_pool.m?rev=174648&r1=174647&r2=174648&view=diff
==============================================================================
--- cfe/trunk/test/Modules/method_pool.m (original)
+++ cfe/trunk/test/Modules/method_pool.m Thu Feb  7 13:13:24 2013
@@ -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 at 2{{using}}
   // expected-note at 2{{also found}}
 }
+
+void testMethod4Again(id object) {
+  [object method4];
+} 





More information about the cfe-commits mailing list