With -Wselector, don't warn about unimplemented optional method

used in @selector expression because, well, their implementation 
is optional. // rdar://9545564

llvm-svn: 135057
This commit is contained in:
Fariborz Jahanian 2011-07-13 19:05:43 +00:00
parent b7cdd8772c
commit 9a881019a5
2 changed files with 33 additions and 5 deletions

View File

@ -178,11 +178,14 @@ ExprResult Sema::ParseObjCSelectorExpression(Selector Sel,
SourceRange(LParenLoc, RParenLoc));
if (!Method)
Diag(SelLoc, diag::warn_undeclared_selector) << Sel;
llvm::DenseMap<Selector, SourceLocation>::iterator Pos
= ReferencedSelectors.find(Sel);
if (Pos == ReferencedSelectors.end())
ReferencedSelectors.insert(std::make_pair(Sel, SelLoc));
if (!Method ||
Method->getImplementationControl() != ObjCMethodDecl::Optional) {
llvm::DenseMap<Selector, SourceLocation>::iterator Pos
= ReferencedSelectors.find(Sel);
if (Pos == ReferencedSelectors.end())
ReferencedSelectors.insert(std::make_pair(Sel, SelLoc));
}
// In ARC, forbid the user from using @selector for
// retain/release/autorelease/dealloc/retainCount.

View File

@ -27,3 +27,28 @@ SEL func()
{
return @selector(length); // expected-warning {{unimplemented selector 'length'}}
}
// rdar://9545564
@class MSPauseManager;
@protocol MSPauseManagerDelegate
@optional
- (void)pauseManagerDidPause:(MSPauseManager *)manager;
- (int)respondsToSelector:(SEL)aSelector;
@end
@interface MSPauseManager
{
id<MSPauseManagerDelegate> _delegate;
}
@end
@implementation MSPauseManager
- (id) Meth {
if ([_delegate respondsToSelector:@selector(pauseManagerDidPause:)])
return 0;
return 0;
}
@end