From 560b7fa0c44df3cc4f03b396957aaf7e8e6a8fc8 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Thu, 7 Feb 2013 19:13:24 +0000 Subject: [PATCH] Retain all hidden methods in the global method pool, because they may become visible . llvm-svn: 174648 --- clang/lib/Sema/SemaDeclObjC.cpp | 4 ++++ clang/test/Modules/Inputs/MethodPoolASub.h | 1 + clang/test/Modules/Inputs/MethodPoolBSub.h | 1 + clang/test/Modules/Inputs/module.map | 4 ++++ clang/test/Modules/method_pool.m | 8 ++++++++ 5 files changed, 18 insertions(+) diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index 0b09697..43b097d 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/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/clang/test/Modules/Inputs/MethodPoolASub.h b/clang/test/Modules/Inputs/MethodPoolASub.h index e0bd238..0b36dfa 100644 --- a/clang/test/Modules/Inputs/MethodPoolASub.h +++ b/clang/test/Modules/Inputs/MethodPoolASub.h @@ -1,3 +1,4 @@ @interface A (Sub) - (char)method3; +- (char*)method4; @end diff --git a/clang/test/Modules/Inputs/MethodPoolBSub.h b/clang/test/Modules/Inputs/MethodPoolBSub.h index 3404ce9..0a7899d 100644 --- a/clang/test/Modules/Inputs/MethodPoolBSub.h +++ b/clang/test/Modules/Inputs/MethodPoolBSub.h @@ -1,3 +1,4 @@ @interface B (Sub) - (char *)method3; +- (char*)method4; @end diff --git a/clang/test/Modules/Inputs/module.map b/clang/test/Modules/Inputs/module.map index 234bfcc..499dcba 100644 --- a/clang/test/Modules/Inputs/module.map +++ b/clang/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/clang/test/Modules/method_pool.m b/clang/test/Modules/method_pool.m index 1b94efb..712e55d 100644 --- a/clang/test/Modules/method_pool.m +++ b/clang/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]; +} -- 2.7.4