r204065 - Objective-C. Do not warn when an instance method and

Fariborz Jahanian fjahanian at apple.com
Mon Mar 17 10:46:10 PDT 2014


Author: fjahanian
Date: Mon Mar 17 12:46:10 2014
New Revision: 204065

URL: http://llvm.org/viewvc/llvm-project?rev=204065&view=rev
Log:
Objective-C. Do not warn when an instance method and
class method with the same selctor but different argument 
types having one of them in class extension.
// rdar://16312105

Modified:
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp
    cfe/trunk/test/SemaObjC/class-extension-dup-methods.m

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=204065&r1=204064&r2=204065&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Mon Mar 17 12:46:10 2014
@@ -838,7 +838,9 @@ void Sema::DiagnoseClassExtensionDupMeth
     return;
   for (const auto *Method : CAT->methods()) {
     const ObjCMethodDecl *&PrevMethod = MethodMap[Method->getSelector()];
-    if (PrevMethod && !MatchTwoMethodDeclarations(Method, PrevMethod)) {
+    if (PrevMethod &&
+        (PrevMethod->isInstanceMethod() == Method->isInstanceMethod()) &&
+        !MatchTwoMethodDeclarations(Method, PrevMethod)) {
       Diag(Method->getLocation(), diag::err_duplicate_method_decl)
             << Method->getDeclName();
       Diag(PrevMethod->getLocation(), diag::note_previous_declaration);

Modified: cfe/trunk/test/SemaObjC/class-extension-dup-methods.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/class-extension-dup-methods.m?rev=204065&r1=204064&r2=204065&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/class-extension-dup-methods.m (original)
+++ cfe/trunk/test/SemaObjC/class-extension-dup-methods.m Mon Mar 17 12:46:10 2014
@@ -13,3 +13,16 @@
 + (int)  InstMeth;
 - (int) OK;
 @end
+
+// rdar://16312105
+ at class NSObject;
+
+__attribute__((objc_root_class)) @interface AppDelegate
++ (void)someMethodWithArgument:(NSObject *)argument;
++ (void)someMethodWithArgument:(NSObject *)argument : (NSObject*) argument2; // expected-note {{previous declaration is here}}
+ at end
+
+ at interface AppDelegate ()
+- (void)someMethodWithArgument:(float)argument; // OK. No warning to be issued here.
++ (void)someMethodWithArgument:(float)argument : (float)argument2; // expected-error {{duplicate declaration of method 'someMethodWithArgument::'}}
+ at end





More information about the cfe-commits mailing list