]> granicus.if.org Git - clang/commitdiff
Objective-C: Fixes a typo correction bug where a
authorFariborz Jahanian <fjahanian@apple.com>
Tue, 18 Jun 2013 17:10:58 +0000 (17:10 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Tue, 18 Jun 2013 17:10:58 +0000 (17:10 +0000)
selector would be correted to identical selector name
in certain corner cases. // rdar://7853549

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184208 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclObjC.cpp
lib/Sema/SemaExprObjC.cpp
test/SemaObjC/call-super-2.m

index b62487bee72955e19532551ff766b5b43fc64237..9f10b7bb7ea91db99b1eb63ddd2b793bb32abf9b 100644 (file)
@@ -2331,7 +2331,8 @@ Sema::SelectorsForTypoCorrection(Selector Sel,
     // instance methods
     for (ObjCMethodList *M = &b->second.first; M; M=M->getNext())
       if (M->Method &&
-          (M->Method->getSelector().getNumArgs() == NumArgs)) {
+          (M->Method->getSelector().getNumArgs() == NumArgs) &&
+          (M->Method->getSelector() != Sel)) {
         if (ObjectIsId)
           Methods.push_back(M->Method);
         else if (!ObjectIsClass &&
@@ -2341,7 +2342,8 @@ Sema::SelectorsForTypoCorrection(Selector Sel,
     // class methods
     for (ObjCMethodList *M = &b->second.second; M; M=M->getNext())
       if (M->Method &&
-          (M->Method->getSelector().getNumArgs() == NumArgs)) {
+          (M->Method->getSelector().getNumArgs() == NumArgs) &&
+          (M->Method->getSelector() != Sel)) {
         if (ObjectIsClass)
           Methods.push_back(M->Method);
         else if (!ObjectIsId &&
index 678a1291ae186b9c0e357f8f8afccadfaff5098c..2944422c5553a9ca9a045507ce2e793cac39d0de 100644 (file)
@@ -1233,7 +1233,7 @@ bool Sema::CheckMessageArgumentTypes(QualType ReceiverType,
                               : diag::warn_inst_method_not_found;
     if (!getLangOpts().DebuggerSupport) {
       const ObjCMethodDecl *OMD = SelectorsForTypoCorrection(Sel, ReceiverType);
-      if (OMD && !OMD->isInvalidDecl() && OMD->getSelector() != Sel) {
+      if (OMD && !OMD->isInvalidDecl()) {
         if (getLangOpts().ObjCAutoRefCount)
           DiagID = diag::error_method_not_found_with_typo;
         else
index c33e7ab2645bdba3695b9dcdb18c9189ebfba337..8927f3b528648fa794edcae55e2b038dc27d675f 100644 (file)
@@ -35,7 +35,7 @@ id objc_getClass(const char *s);
 @implementation Derived
 + (int) class_func1
 {
-   int i = (size_t)[self class_func0];       // expected-warning {{class method '+class_func0' not found (return type defaults to 'id')}}
+   int i = (size_t)[self class_func0];       // expected-warning {{class method '+class_func0' not found (return type defaults to 'id'); did you mean '+class_func}}
    return i + (size_t)[super class_func0];   // expected-warning {{class method '+class_func0' not found (return type defaults to 'id')}}
 }
 + (int) class_func2