diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2014-08-27 16:38:47 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2014-08-27 16:38:47 +0000 |
commit | 180d76b4089e74bb08e2b00d20c5eabba8eaa024 (patch) | |
tree | fb06cb3cdfdfc0d602373cf42e8e1df292995579 /clang/lib/Sema/SemaOverload.cpp | |
parent | 1d6082ff1753cf238f62b2b4f048f86d1fedd209 (diff) | |
download | bcm5719-llvm-180d76b4089e74bb08e2b00d20c5eabba8eaa024.tar.gz bcm5719-llvm-180d76b4089e74bb08e2b00d20c5eabba8eaa024.zip |
Objective-C. When multiple nullary selectors are found in
global pool in the course of method selection for
a messaging expression, select one with the most general
return type of 'id'. This is to remove type-mismatch
warning (which is useless) as result of random selection of
method with more restrictive return type. rdar://18095772
llvm-svn: 216560
Diffstat (limited to 'clang/lib/Sema/SemaOverload.cpp')
-rw-r--r-- | clang/lib/Sema/SemaOverload.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 7bc42bfe9cb..95b1dc09062 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -5743,10 +5743,20 @@ ObjCMethodDecl *Sema::SelectBestMethod(Selector Sel, MultiExprArg Args, break; } } - } else + } else { // Check for extra arguments to non-variadic methods. if (Args.size() != NumNamedArgs) Match = false; + else if (Match && NumNamedArgs == 0 && Methods.size() > 1) { + // Special case when selectors have no argument. In this case, select + // one with the most general result type of 'id'. + for (unsigned b = 0, e = Methods.size(); b < e; b++) { + QualType ReturnT = Methods[b]->getReturnType(); + if (ReturnT->isObjCIdType()) + return Methods[b]; + } + } + } if (Match) return Method; |