diff options
author | Steve Naroff <snaroff@apple.com> | 2008-09-30 14:38:43 +0000 |
---|---|---|
committer | Steve Naroff <snaroff@apple.com> | 2008-09-30 14:38:43 +0000 |
commit | 4a82d815de070537545538ac1fbfaafa48cb97bf (patch) | |
tree | 4a617b7ebeeb18991d4c9a35943ddd8ee19ebb4f /clang/lib/Sema/SemaExprObjC.cpp | |
parent | a459f128621bf5652336dea5e2513688b811f476 (diff) | |
download | bcm5719-llvm-4a82d815de070537545538ac1fbfaafa48cb97bf.tar.gz bcm5719-llvm-4a82d815de070537545538ac1fbfaafa48cb97bf.zip |
Fix <rdar://problem/6191148> [sema] Objective-C method lookup (at global scope) fails to handle overloaded selectors properly.
Long standing bug in Sema::ActOnInstanceMessage(). We now warn when messaging an "id" with multiple method signatures in scope. The diags are a little verbose, however they can be streamlined if necessary.
llvm-svn: 56843
Diffstat (limited to 'clang/lib/Sema/SemaExprObjC.cpp')
-rw-r--r-- | clang/lib/Sema/SemaExprObjC.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp index db834052836..a474b7eee78 100644 --- a/clang/lib/Sema/SemaExprObjC.cpp +++ b/clang/lib/Sema/SemaExprObjC.cpp @@ -283,7 +283,8 @@ Sema::ExprResult Sema::ActOnInstanceMessage(ExprTy *receiver, Selector Sel, // Handle messages to id. if (ReceiverCType == Context.getCanonicalType(Context.getObjCIdType()) || ReceiverCType->getAsBlockPointerType()) { - ObjCMethodDecl *Method = InstanceMethodPool[Sel].Method; + ObjCMethodDecl *Method = LookupInstanceMethodInGlobalPool( + Sel, SourceRange(lbrac,rbrac)); if (!Method) Method = FactoryMethodPool[Sel].Method; if (CheckMessageArgumentTypes(ArgExprs, NumArgs, Sel, Method, "-", @@ -306,7 +307,8 @@ Sema::ExprResult Sema::ActOnInstanceMessage(ExprTy *receiver, Selector Sel, if (!Method) Method = FactoryMethodPool[Sel].Method; if (!Method) - Method = InstanceMethodPool[Sel].Method; + Method = LookupInstanceMethodInGlobalPool( + Sel, SourceRange(lbrac,rbrac)); if (CheckMessageArgumentTypes(ArgExprs, NumArgs, Sel, Method, "-", lbrac, rbrac, returnType)) return true; @@ -335,9 +337,9 @@ Sema::ExprResult Sema::ActOnInstanceMessage(ExprTy *receiver, Selector Sel, // We allow sending a message to a pointer to an interface (an object). ClassDecl = OCIReceiver->getDecl(); - // FIXME: consider using InstanceMethodPool, since it will be faster - // than the following method (which can do *many* linear searches). The - // idea is to add class info to InstanceMethodPool. + // FIXME: consider using LookupInstanceMethodInGlobalPool, since it will be + // faster than the following method (which can do *many* linear searches). + // The idea is to add class info to InstanceMethodPool. Method = ClassDecl->lookupInstanceMethod(Sel); if (!Method) { @@ -369,7 +371,8 @@ Sema::ExprResult Sema::ActOnInstanceMessage(ExprTy *receiver, Selector Sel, // behavior isn't very desirable, however we need it for GCC // compatibility. if (!Method) - Method = InstanceMethodPool[Sel].Method; + Method = LookupInstanceMethodInGlobalPool( + Sel, SourceRange(lbrac,rbrac)); } if (CheckMessageArgumentTypes(ArgExprs, NumArgs, Sel, Method, "-", lbrac, rbrac, returnType)) |