r236006 - Fix PR22047: ObjC: Method unavailability attribute doesn't work with overloaded methods

Jonathan Roelofs jonathan at codesourcery.com
Tue Apr 28 11:04:44 PDT 2015


Author: jroelofs
Date: Tue Apr 28 13:04:44 2015
New Revision: 236006

URL: http://llvm.org/viewvc/llvm-project?rev=236006&view=rev
Log:
Fix PR22047: ObjC: Method unavailability attribute doesn't work with overloaded methods

http://reviews.llvm.org/D9261

Added:
    cfe/trunk/test/SemaObjC/multiple-method-names.m
Modified:
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=236006&r1=236005&r2=236006&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Tue Apr 28 13:04:44 2015
@@ -2385,10 +2385,10 @@ bool Sema::AreMultipleMethodsInGlobalPoo
   // Diagnose finding more than one method in global pool
   SmallVector<ObjCMethodDecl *, 4> Methods;
   Methods.push_back(BestMethod);
-  for (ObjCMethodList *M = &MethList; M; M = M->getNext())
-    if (M->getMethod() && !M->getMethod()->isHidden() &&
-        M->getMethod() != BestMethod)
-      Methods.push_back(M->getMethod());
+  for (ObjCMethodList *ML = &MethList; ML; ML = ML->getNext())
+    if (ObjCMethodDecl *M = ML->getMethod())
+      if (!M->isHidden() && M != BestMethod && !M->hasAttr<UnavailableAttr>())
+        Methods.push_back(M);
   if (Methods.size() > 1)
     DiagnoseMultipleMethodInGlobalPool(Methods, Sel, R, receiverIdOrClass);
 
@@ -2420,7 +2420,7 @@ void Sema::DiagnoseMultipleMethodInGloba
                                               bool receiverIdOrClass) {
   // We found multiple methods, so we may have to complain.
   bool issueDiagnostic = false, issueError = false;
-  
+
   // We support a warning which complains about *any* difference in
   // method signature.
   bool strictSelectorMatch =
@@ -2434,7 +2434,7 @@ void Sema::DiagnoseMultipleMethodInGloba
       }
     }
   }
-  
+
   // If we didn't see any strict differences, we won't see any loose
   // differences.  In ARC, however, we also need to check for loose
   // mismatches, because most of them are errors.

Added: cfe/trunk/test/SemaObjC/multiple-method-names.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/multiple-method-names.m?rev=236006&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjC/multiple-method-names.m (added)
+++ cfe/trunk/test/SemaObjC/multiple-method-names.m Tue Apr 28 13:04:44 2015
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -Wobjc-multiple-method-names -x objective-c %s -verify
+// PR22047
+
+ at interface Face0
+- (void)foo:(float)i; // expected-note {{using}}
+ at end
+
+ at interface Face1
+- (void)foo:(int)i __attribute__((unavailable));
+ at end
+
+ at interface Face2
+- (void)foo:(char)i; // expected-note {{also found}}
+ at end
+
+void f(id i) {
+  [i foo:4.0f]; // expected-warning {{multiple methods named 'foo:' found}}
+}
+





More information about the cfe-commits mailing list