r208443 - Objective-C. Reduce false positive warnings with -Wselector by issuing warning
Fariborz Jahanian
fjahanian at apple.com
Fri May 9 12:51:39 PDT 2014
Author: fjahanian
Date: Fri May 9 14:51:39 2014
New Revision: 208443
URL: http://llvm.org/viewvc/llvm-project?rev=208443&view=rev
Log:
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
Added:
cfe/trunk/test/SemaObjC/selector-4.m
Modified:
cfe/trunk/lib/Sema/SemaExprObjC.cpp
cfe/trunk/test/PCH/Inputs/chain-selectors2.h
cfe/trunk/test/SemaObjC/selector-3.m
Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=208443&r1=208442&r2=208443&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Fri May 9 14:51:39 2014
@@ -1049,8 +1049,9 @@ ExprResult Sema::ParseObjCSelectorExpres
} 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())
Modified: cfe/trunk/test/PCH/Inputs/chain-selectors2.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/Inputs/chain-selectors2.h?rev=208443&r1=208442&r2=208443&view=diff
==============================================================================
--- cfe/trunk/test/PCH/Inputs/chain-selectors2.h (original)
+++ cfe/trunk/test/PCH/Inputs/chain-selectors2.h Fri May 9 14:51:39 2014
@@ -1,6 +1,8 @@
@interface Y
-(void)f;
-(void)f2;
+ -(void)x;
+ -(void)y;
-(void)e;
@end
Modified: cfe/trunk/test/SemaObjC/selector-3.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/selector-3.m?rev=208443&r1=208442&r2=208443&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/selector-3.m (original)
+++ cfe/trunk/test/SemaObjC/selector-3.m Fri May 9 14:51:39 2014
@@ -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: ))] )
{
}
Added: cfe/trunk/test/SemaObjC/selector-4.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/selector-4.m?rev=208443&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjC/selector-4.m (added)
+++ cfe/trunk/test/SemaObjC/selector-4.m Fri May 9 14:51:39 2014
@@ -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
+
+ at interface NSObject @end
+ at interface NSString @end
+
+ at interface NSString (NSStringExtensionMethods)
+- (void)compare:(NSString *)string;
+ at end
+
+ at interface MyObject : NSObject
+ at end
+
+#else
+int main() {
+ (void)@selector(compare:);
+}
+
+ at implementation MyObject
+
+ at end
+#endif
More information about the cfe-commits
mailing list