]> granicus.if.org Git - clang/commitdiff
Objective-C. Minor refactoring of my last patch.
authorFariborz Jahanian <fjahanian@apple.com>
Wed, 13 Aug 2014 21:24:14 +0000 (21:24 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Wed, 13 Aug 2014 21:24:14 +0000 (21:24 +0000)
// rdar://16808765

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

include/clang/Sema/Sema.h
lib/Sema/SemaExprObjC.cpp
lib/Sema/SemaOverload.cpp

index db8ba03d5158afe445f78222a8a1fa5828c80faf..25645ea6fc5a6a3aa130773281d5e92bb08a1cb6 100644 (file)
@@ -2894,7 +2894,7 @@ private:
   /// \brief - Returns a selector which best matches given argument list or
   /// nullptr if none could be found
   ObjCMethodDecl *SelectBestMethod(Selector Sel, MultiExprArg Args,
-                                   SmallVectorImpl<ObjCMethodDecl*>& Methods);
+                                   bool IsInstance);
     
 
   /// \brief Record the typo correction failure and return an empty correction.
index 6cc1658934d48276717d592eeaa5290b08d2ebd1..80ce9baee7526c6dc60ef28906f5872ce53f1466 100644 (file)
@@ -2418,13 +2418,10 @@ ExprResult Sema::BuildInstanceMessage(Expr *Receiver,
         Method = LookupFactoryMethodInGlobalPool(Sel, 
                                                  SourceRange(LBracLoc,RBracLoc),
                                                  receiverIsId);
-      if (Method) {
-        SmallVector<ObjCMethodDecl*, 4> Methods;
-        if (CollectMultipleMethodsInGlobalPool(Sel, Methods,
-                                               Method->isInstanceMethod()))
-          if (ObjCMethodDecl *BestMethod = SelectBestMethod(Sel, ArgsIn, Methods))
-            Method = BestMethod;
-      }
+      if (Method)
+        if (ObjCMethodDecl *BestMethod =
+                SelectBestMethod(Sel, ArgsIn, Method->isInstanceMethod()))
+          Method = BestMethod;
     } else if (ReceiverType->isObjCClassType() ||
                ReceiverType->isObjCQualifiedClassType()) {
       // Handle messages to Class.
index 660d60da2a380bedb300ab4040c09fe1c489a2b1..09469cea772e14d7b6cdcf4160477b77a6ab8f72 100644 (file)
@@ -5678,7 +5678,11 @@ Sema::AddOverloadCandidate(FunctionDecl *Function,
 }
 
 ObjCMethodDecl *Sema::SelectBestMethod(Selector Sel, MultiExprArg Args,
-                                       SmallVectorImpl<ObjCMethodDecl*>& Methods) {
+                                       bool IsInstance) {
+  SmallVector<ObjCMethodDecl*, 4> Methods;
+  if (!CollectMultipleMethodsInGlobalPool(Sel, Methods, IsInstance))
+    return nullptr;
+    
   for (unsigned b = 0, e = Methods.size(); b < e; b++) {
     bool Match = true;
     ObjCMethodDecl *Method = Methods[b];