From 33ab4d05a0f75b13d8c5d3a0e80ad9115716cae1 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Fri, 10 Jan 2014 19:27:21 +0000 Subject: [PATCH] ObjectiveC. Remove warning on mismatched methods which may belong to unrelated classes. It was primarily intended for miuse of @selector expression. But warning is too noisy and will be issued when an actual @selector is used. // rdar://15740134 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198952 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/DiagnosticSemaKinds.td | 2 - include/clang/Sema/Sema.h | 6 --- lib/Sema/SemaDeclObjC.cpp | 47 ---------------------- test/SemaObjC/selector-3.m | 14 +++---- 4 files changed, 7 insertions(+), 62 deletions(-) diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 974533e44f..a43ce7f32b 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -856,8 +856,6 @@ def warn_auto_implicit_atomic_property : Warning< InGroup, DefaultIgnore; def warn_unimplemented_selector: Warning< "creating selector for nonexistent method %0">, InGroup, DefaultIgnore; -def warning_multiple_selectors: Warning< - "multiple selectors named %0 found">, InGroup, DefaultIgnore; def warn_unimplemented_protocol_method : Warning< "method %0 in protocol %1 not implemented">, InGroup; diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index 733f0262e2..d5ba71a3d1 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -2785,12 +2785,6 @@ public: const ObjCMethodDecl *SelectorsForTypoCorrection(Selector Sel, QualType ObjectType=QualType()); - - /// DiagnoseMismatchedMethodsInGlobalPool - This routine goes through list of - /// methods in global pool and issues diagnostic on identical selectors which - /// have mismathched types. - void DiagnoseMismatchedMethodsInGlobalPool(); - /// LookupImplementedMethodInGlobalPool - Returns the method which has an /// implementation. ObjCMethodDecl *LookupImplementedMethodInGlobalPool(Selector Sel); diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index 5bd0ac51a7..34d1965fa5 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -2469,51 +2469,6 @@ Sema::SelectorsForTypoCorrection(Selector Sel, return (SelectedMethods.size() == 1) ? SelectedMethods[0] : NULL; } -static void -HelperToDiagnoseMismatchedMethodsInGlobalPool(Sema &S, - ObjCMethodList &MethList) { - ObjCMethodList *M = &MethList; - ObjCMethodDecl *TargetMethod = M->Method; - while (TargetMethod && - isa(TargetMethod->getDeclContext())) { - M = M->getNext(); - TargetMethod = M ? M->Method : 0; - } - if (!TargetMethod) - return; - bool FirstTime = true; - for (M = M->getNext(); M; M=M->getNext()) { - ObjCMethodDecl *MatchingMethodDecl = M->Method; - if (isa(MatchingMethodDecl->getDeclContext())) - continue; - if (!S.MatchTwoMethodDeclarations(TargetMethod, - MatchingMethodDecl, Sema::MMS_loose)) { - if (FirstTime) { - FirstTime = false; - S.Diag(TargetMethod->getLocation(), diag::warning_multiple_selectors) - << TargetMethod->getSelector(); - } - S.Diag(MatchingMethodDecl->getLocation(), diag::note_also_found); - } - } -} - -void Sema::DiagnoseMismatchedMethodsInGlobalPool() { - unsigned DIAG = diag::warning_multiple_selectors; - if (Diags.getDiagnosticLevel(DIAG, SourceLocation()) - == DiagnosticsEngine::Ignored) - return; - for (GlobalMethodPool::iterator b = MethodPool.begin(), - e = MethodPool.end(); b != e; b++) { - // first, instance methods - ObjCMethodList &InstMethList = b->second.first; - HelperToDiagnoseMismatchedMethodsInGlobalPool(*this, InstMethList); - // second, class methods - ObjCMethodList &ClsMethList = b->second.second; - HelperToDiagnoseMismatchedMethodsInGlobalPool(*this, ClsMethList); - } -} - /// DiagnoseDuplicateIvars - /// Check for duplicate ivars in the entire class at the start of /// \@implementation. This becomes necesssary because class extension can @@ -3470,8 +3425,6 @@ void Sema::DiagnoseUseOfUnimplementedSelectors() { ReferencedSelectors[Sels[I].first] = Sels[I].second; } - DiagnoseMismatchedMethodsInGlobalPool(); - // Warning will be issued only when selector table is // generated (which means there is at lease one implementation // in the TU). This is to match gcc's behavior. diff --git a/test/SemaObjC/selector-3.m b/test/SemaObjC/selector-3.m index d782c784f1..35a4651707 100644 --- a/test/SemaObjC/selector-3.m +++ b/test/SemaObjC/selector-3.m @@ -84,23 +84,23 @@ extern SEL MySelector(SEL s); // rdar://14007194 @interface UxTechTest : NSObject -- (int) invalidate : (id)Arg; // expected-warning {{multiple selectors named 'invalidate:' found}} -+ (int) C_invalidate : (int)arg; // expected-warning {{multiple selectors named 'C_invalidate:' found}} +- (int) invalidate : (id)Arg; ++ (int) C_invalidate : (int)arg; @end @interface UxTechTest(CAT) -- (char) invalidate : (int)arg; // expected-note {{also found}} -+ (int) C_invalidate : (char)arg; // expected-note {{also found}} +- (char) invalidate : (int)arg; ++ (int) C_invalidate : (char)arg; @end @interface NSPort : NSObject -- (double) invalidate : (void*)Arg1; // expected-note {{also found}} -+ (int) C_invalidate : (id*)arg; // expected-note {{also found}} +- (double) invalidate : (void*)Arg1; ++ (int) C_invalidate : (id*)arg; @end @interface USEText : NSPort -- (int) invalidate : (int)arg; // expected-note {{also found}} +- (int) invalidate : (int)arg; @end @implementation USEText -- 2.40.0