From: Douglas Gregor Date: Thu, 7 Feb 2013 19:13:24 +0000 (+0000) Subject: Retain all hidden methods in the global method pool, because they may become visible... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7666b03d499819214752ae392efe666ca856d0e7;p=clang Retain all hidden methods in the global method pool, because they may become visible . git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174648 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index 0b09697a8f..43b097d1f2 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -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() != right->hasAttr() || diff --git a/test/Modules/Inputs/MethodPoolASub.h b/test/Modules/Inputs/MethodPoolASub.h index e0bd238567..0b36dfa660 100644 --- a/test/Modules/Inputs/MethodPoolASub.h +++ b/test/Modules/Inputs/MethodPoolASub.h @@ -1,3 +1,4 @@ @interface A (Sub) - (char)method3; +- (char*)method4; @end diff --git a/test/Modules/Inputs/MethodPoolBSub.h b/test/Modules/Inputs/MethodPoolBSub.h index 3404ce91fa..0a7899df81 100644 --- a/test/Modules/Inputs/MethodPoolBSub.h +++ b/test/Modules/Inputs/MethodPoolBSub.h @@ -1,3 +1,4 @@ @interface B (Sub) - (char *)method3; +- (char*)method4; @end diff --git a/test/Modules/Inputs/module.map b/test/Modules/Inputs/module.map index 234bfcc2b0..499dcba279 100644 --- a/test/Modules/Inputs/module.map +++ b/test/Modules/Inputs/module.map @@ -116,6 +116,10 @@ module templates_right { module MethodPoolA { header "MethodPoolA.h" + explicit module Sub2 { + header "MethodPoolASub2.h" + } + explicit module Sub { header "MethodPoolASub.h" } diff --git a/test/Modules/method_pool.m b/test/Modules/method_pool.m index 1b94efb79f..712e55d4d6 100644 --- a/test/Modules/method_pool.m +++ b/test/Modules/method_pool.m @@ -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]; +}