From dc812ef2ed5d41e1696c08f0c4c21a94c21b4521 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Wed, 13 Aug 2014 21:24:14 +0000 Subject: [PATCH] Objective-C. Minor refactoring of my last patch. // rdar://16808765 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215581 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Sema/Sema.h | 2 +- lib/Sema/SemaExprObjC.cpp | 11 ++++------- lib/Sema/SemaOverload.cpp | 6 +++++- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index db8ba03d51..25645ea6fc 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -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& Methods); + bool IsInstance); /// \brief Record the typo correction failure and return an empty correction. diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp index 6cc1658934..80ce9baee7 100644 --- a/lib/Sema/SemaExprObjC.cpp +++ b/lib/Sema/SemaExprObjC.cpp @@ -2418,13 +2418,10 @@ ExprResult Sema::BuildInstanceMessage(Expr *Receiver, Method = LookupFactoryMethodInGlobalPool(Sel, SourceRange(LBracLoc,RBracLoc), receiverIsId); - if (Method) { - SmallVector 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. diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index 660d60da2a..09469cea77 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -5678,7 +5678,11 @@ Sema::AddOverloadCandidate(FunctionDecl *Function, } ObjCMethodDecl *Sema::SelectBestMethod(Selector Sel, MultiExprArg Args, - SmallVectorImpl& Methods) { + bool IsInstance) { + SmallVector 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]; -- 2.40.0