[cfe-commits] r135057 - in /cfe/trunk: lib/Sema/SemaExprObjC.cpp test/SemaObjC/selector-3.m

Fariborz Jahanian fjahanian at apple.com
Wed Jul 13 12:05:43 PDT 2011


Author: fjahanian
Date: Wed Jul 13 14:05:43 2011
New Revision: 135057

URL: http://llvm.org/viewvc/llvm-project?rev=135057&view=rev
Log:
With -Wselector, don't warn about unimplemented optional method
used in @selector expression because, well, their implementation 
is optional. // rdar://9545564

Modified:
    cfe/trunk/lib/Sema/SemaExprObjC.cpp
    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=135057&r1=135056&r2=135057&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Wed Jul 13 14:05:43 2011
@@ -178,11 +178,14 @@
                                           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.

Modified: cfe/trunk/test/SemaObjC/selector-3.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/selector-3.m?rev=135057&r1=135056&r2=135057&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/selector-3.m (original)
+++ cfe/trunk/test/SemaObjC/selector-3.m Wed Jul 13 14:05:43 2011
@@ -27,3 +27,28 @@
 {
     return  @selector(length);  // expected-warning {{unimplemented selector 'length'}}
 }
+
+// rdar://9545564
+ at class MSPauseManager;
+
+ at protocol MSPauseManagerDelegate 
+ at optional
+- (void)pauseManagerDidPause:(MSPauseManager *)manager;
+- (int)respondsToSelector:(SEL)aSelector;
+ at end
+
+ at interface MSPauseManager
+{
+  id<MSPauseManagerDelegate> _delegate;
+}
+ at end
+
+
+ at implementation MSPauseManager
+- (id) Meth {
+  if ([_delegate respondsToSelector:@selector(pauseManagerDidPause:)])
+    return 0;
+  return 0;
+}
+ at end
+





More information about the cfe-commits mailing list