<div dir="ltr">This is causing <a href="http://llvm.org/bugs/show_bug.cgi?id=21587">http://llvm.org/bugs/show_bug.cgi?id=21587</a><div><br></div><div>Looks like Sema::CollectMultipleMethodsInGlobalPool() should probably also look at stuff from an external sema source?</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Nov 7, 2014 at 3:51 PM, Fariborz Jahanian <span dir="ltr"><<a href="mailto:fjahanian@apple.com" target="_blank">fjahanian@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: fjahanian<br>
Date: Fri Nov  7 17:51:15 2014<br>
New Revision: 221562<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=221562&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=221562&view=rev</a><br>
Log:<br>
[Objective-C Sema]. Issue availability/deprecated warning when<br>
there is a uinque method found when message is sent to receiver<br>
of 'id' type. // rdar://18848183<br>
<br>
Modified:<br>
    cfe/trunk/lib/Sema/SemaExprObjC.cpp<br>
    cfe/trunk/test/ARCMT/checking.m<br>
    cfe/trunk/test/SemaObjC/attr-deprecated.m<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=221562&r1=221561&r2=221562&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=221562&r1=221561&r2=221562&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Fri Nov  7 17:51:15 2014<br>
@@ -2448,10 +2448,14 @@ ExprResult Sema::BuildInstanceMessage(Ex<br>
         Method = LookupFactoryMethodInGlobalPool(Sel,<br>
                                                  SourceRange(LBracLoc,RBracLoc),<br>
                                                  receiverIsId);<br>
-      if (Method)<br>
+      if (Method) {<br>
         if (ObjCMethodDecl *BestMethod =<br>
               SelectBestMethod(Sel, ArgsIn, Method->isInstanceMethod()))<br>
           Method = BestMethod;<br>
+          SmallVector<ObjCMethodDecl*, 4> Methods;<br>
+          if (!CollectMultipleMethodsInGlobalPool(Sel, Methods, Method->isInstanceMethod()))<br>
+            DiagnoseUseOfDecl(Method, SelLoc);<br>
+      }<br>
     } else if (ReceiverType->isObjCClassType() ||<br>
                ReceiverType->isObjCQualifiedClassType()) {<br>
       // Handle messages to Class.<br>
<br>
Modified: cfe/trunk/test/ARCMT/checking.m<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/checking.m?rev=221562&r1=221561&r2=221562&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/checking.m?rev=221562&r1=221561&r2=221562&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/ARCMT/checking.m (original)<br>
+++ cfe/trunk/test/ARCMT/checking.m Fri Nov  7 17:51:15 2014<br>
@@ -14,9 +14,9 @@ typedef int BOOL;<br>
 typedef unsigned NSUInteger;<br>
<br>
 @protocol NSObject<br>
-- (id)retain NS_AUTOMATED_REFCOUNT_UNAVAILABLE;<br>
+- (id)retain NS_AUTOMATED_REFCOUNT_UNAVAILABLE; // expected-note {{'retain' has been explicitly marked unavailable here}}<br>
 - (NSUInteger)retainCount NS_AUTOMATED_REFCOUNT_UNAVAILABLE;<br>
-- (oneway void)release NS_AUTOMATED_REFCOUNT_UNAVAILABLE;<br>
+- (oneway void)release NS_AUTOMATED_REFCOUNT_UNAVAILABLE; // expected-note 4 {{'release' has been explicitly marked unavailable here}}<br>
 - (id)autorelease NS_AUTOMATED_REFCOUNT_UNAVAILABLE;<br>
 @end<br>
<br>
@@ -74,16 +74,20 @@ id global_foo;<br>
<br>
 void test1(A *a, BOOL b, struct UnsafeS *unsafeS) {<br>
   [[a delegate] release]; // expected-error {{it is not safe to remove 'retain' message on the result of a 'delegate' message; the object that was passed to 'setDelegate:' may not be properly retained}} \<br>
+                         // expected-error {{'release' is unavailable: not available in automatic reference counting mode}} \<br>
                           // expected-error {{ARC forbids explicit message send}}<br>
   [a.delegate release]; // expected-error {{it is not safe to remove 'retain' message on the result of a 'delegate' message; the object that was passed to 'setDelegate:' may not be properly retained}} \<br>
+                       // expected-error {{'release' is unavailable: not available in automatic reference counting mode}} \<br>
                         // expected-error {{ARC forbids explicit message send}}<br>
   [unsafeS->unsafeObj retain]; // expected-error {{it is not safe to remove 'retain' message on an __unsafe_unretained type}} \<br>
                                // expected-error {{ARC forbids explicit message send}} \<br>
                                // expected-error {{'retain' is unavailable}}<br>
   id foo = [unsafeS->unsafeObj retain]; // no warning.<br>
   [global_foo retain]; // expected-error {{it is not safe to remove 'retain' message on a global variable}} \<br>
+                      // expected-error {{'retain' is unavailable: not available in automatic reference counting mode}} \<br>
                        // expected-error {{ARC forbids explicit message send}}<br>
   [global_foo release]; // expected-error {{it is not safe to remove 'release' message on a global variable}} \<br>
+                       // expected-error {{'release' is unavailable: not available in automatic reference counting mode}} \<br>
                         // expected-error {{ARC forbids explicit message send}}<br>
   [a dealloc];<br>
   [a retain];<br>
@@ -304,7 +308,8 @@ void rdar9491791(int p) {<br>
<br>
 // rdar://9504750<br>
 void rdar9504750(id p) {<br>
-  RELEASE_MACRO(p); // expected-error {{ARC forbids explicit message send of 'release'}}<br>
+  RELEASE_MACRO(p); // expected-error {{ARC forbids explicit message send of 'release'}} \<br>
+                   // expected-error {{'release' is unavailable: not available in automatic reference counting mode}}<br>
 }<br>
<br>
 // rdar://8939557<br>
<br>
Modified: cfe/trunk/test/SemaObjC/attr-deprecated.m<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/attr-deprecated.m?rev=221562&r1=221561&r2=221562&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/attr-deprecated.m?rev=221562&r1=221561&r2=221562&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/SemaObjC/attr-deprecated.m (original)<br>
+++ cfe/trunk/test/SemaObjC/attr-deprecated.m Fri Nov  7 17:51:15 2014<br>
@@ -5,7 +5,7 @@<br>
   int X __attribute__((deprecated)); // expected-note 2 {{'X' has been explicitly marked deprecated here}}<br>
 }<br>
 + (void)F __attribute__((deprecated)); // expected-note 2 {{'F' has been explicitly marked deprecated here}}<br>
-- (void)f __attribute__((deprecated)); // expected-note 4 {{'f' has been explicitly marked deprecated here}}<br>
+- (void)f __attribute__((deprecated)); // expected-note 5 {{'f' has been explicitly marked deprecated here}}<br>
 @end<br>
<br>
 @implementation A<br>
@@ -54,7 +54,7 @@ void t1(A *a)<br>
<br>
 void t2(id a)<br>
 {<br>
-  [a f];<br>
+  [a f]; // expected-warning {{'f' is deprecated}}<br>
 }<br>
<br>
 void t3(A<P>* a)<br>
@@ -228,3 +228,13 @@ expected-note {{property declared here}}<br>
<br>
 @end<br>
<br>
+// rdar://18848183<br>
+@interface NSString<br>
+- (const char *)cString __attribute__((availability(macosx,introduced=10.0 ,deprecated=10.4,message="" ))); // expected-note {{'cString' has been explicitly marked deprecated here}}<br>
+@end<br>
+<br>
+id PID = 0;<br>
+const char * func() {<br>
+  return [PID cString]; // expected-warning {{'cString' is deprecated: first deprecated in OS X 10.4}}<br>
+}<br>
+<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>