forked from OSchip/llvm-project
Objective-C. Reduce false positive warnings with -Wselector by issuing warning
only when named selector is declared in TU and it is not declared in a system header. rdar://16600230 llvm-svn: 208443
This commit is contained in:
parent
0c6a14ca82
commit
65a78b5d9b
|
@ -1049,8 +1049,9 @@ ExprResult Sema::ParseObjCSelectorExpression(Selector Sel,
|
|||
} else
|
||||
DiagnoseMismatchedSelectors(*this, AtLoc, Method);
|
||||
|
||||
if (!Method ||
|
||||
Method->getImplementationControl() != ObjCMethodDecl::Optional) {
|
||||
if (Method &&
|
||||
Method->getImplementationControl() != ObjCMethodDecl::Optional &&
|
||||
!getSourceManager().isInSystemHeader(Method->getLocation())) {
|
||||
llvm::DenseMap<Selector, SourceLocation>::iterator Pos
|
||||
= ReferencedSelectors.find(Sel);
|
||||
if (Pos == ReferencedSelectors.end())
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
@interface Y
|
||||
-(void)f;
|
||||
-(void)f2;
|
||||
-(void)x;
|
||||
-(void)y;
|
||||
-(void)e;
|
||||
@end
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
- (void) foo
|
||||
{
|
||||
SEL a,b,c;
|
||||
a = @selector(b1ar); // expected-warning {{no method with selector 'b1ar' is implemented in this translation unit}}
|
||||
a = @selector(b1ar);
|
||||
b = @selector(bar);
|
||||
}
|
||||
@end
|
||||
|
@ -69,7 +69,7 @@ extern SEL MySelector(SEL s);
|
|||
|
||||
@implementation INTF
|
||||
- (void) Meth {
|
||||
if( [cnx respondsToSelector:MySelector(@selector( _setQueue: ))] ) // expected-warning {{no method with selector '_setQueue:' is implemented in this translation unit}}
|
||||
if( [cnx respondsToSelector:MySelector(@selector( _setQueue: ))] )
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
// RUN: %clang_cc1 -Wselector -x objective-c %s -include %s -verify
|
||||
// expected-no-diagnostics
|
||||
// rdar://16600230
|
||||
|
||||
#ifndef INCLUDED
|
||||
#define INCLUDED
|
||||
|
||||
#pragma clang system_header
|
||||
|
||||
@interface NSObject @end
|
||||
@interface NSString @end
|
||||
|
||||
@interface NSString (NSStringExtensionMethods)
|
||||
- (void)compare:(NSString *)string;
|
||||
@end
|
||||
|
||||
@interface MyObject : NSObject
|
||||
@end
|
||||
|
||||
#else
|
||||
int main() {
|
||||
(void)@selector(compare:);
|
||||
}
|
||||
|
||||
@implementation MyObject
|
||||
|
||||
@end
|
||||
#endif
|
Loading…
Reference in New Issue