<div dir="ltr">Hi Hans,<div><br></div><div>Could you please cherry-pick this change into the release branch?</div><div><br></div><div>Cheers,</div><div>Alex</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 17 Jan 2019 at 10:16, Alex Lorenz via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Author: arphaman<br>
Date: Thu Jan 17 10:12:45 2019<br>
New Revision: 351459<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=351459&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=351459&view=rev</a><br>
Log:<br>
[ObjC] Follow-up r350768 and allow the use of unavailable methods that are<br>
declared in a parent class from within the @implementation context<br>
<br>
This commit extends r350768 and allows the use of methods marked as unavailable<br>
that are declared in a parent class/category from within the @implementation of<br>
the class where the method is marked as unavailable.<br>
This allows users to call init that's marked as unavailable even if they don't<br>
define it.<br>
<br>
rdar://47134898<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D56816" rel="noreferrer" target="_blank">https://reviews.llvm.org/D56816</a><br>
<br>
Modified:<br>
    cfe/trunk/lib/Sema/SemaDeclAttr.cpp<br>
    cfe/trunk/test/SemaObjC/call-unavailable-init-in-self.m<br>
    cfe/trunk/test/SemaObjC/infer-availability-from-init.m<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=351459&r1=351458&r2=351459&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=351459&r1=351458&r2=351459&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Jan 17 10:12:45 2019<br>
@@ -7365,13 +7365,11 @@ ShouldDiagnoseAvailabilityInContext(Sema<br>
         return true;<br>
     } else if (K == AR_Unavailable) {<br>
       // It is perfectly fine to refer to an 'unavailable' Objective-C method<br>
-      // when it's actually defined and is referenced from within the<br>
-      // @implementation itself. In this context, we interpret unavailable as a<br>
-      // form of access control.<br>
+      // when it is referenced from within the @implementation itself. In this<br>
+      // context, we interpret unavailable as a form of access control.<br>
       if (const auto *MD = dyn_cast<ObjCMethodDecl>(OffendingDecl)) {<br>
         if (const auto *Impl = dyn_cast<ObjCImplDecl>(C)) {<br>
-          if (MD->getClassInterface() == Impl->getClassInterface() &&<br>
-              MD->isDefined())<br>
+          if (MD->getClassInterface() == Impl->getClassInterface())<br>
             return true;<br>
         }<br>
       }<br>
<br>
Modified: cfe/trunk/test/SemaObjC/call-unavailable-init-in-self.m<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/call-unavailable-init-in-self.m?rev=351459&r1=351458&r2=351459&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/call-unavailable-init-in-self.m?rev=351459&r1=351458&r2=351459&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/SemaObjC/call-unavailable-init-in-self.m (original)<br>
+++ cfe/trunk/test/SemaObjC/call-unavailable-init-in-self.m Thu Jan 17 10:12:45 2019<br>
@@ -5,13 +5,24 @@<br>
 + (instancetype)new;<br>
 + (instancetype)alloc;<br>
<br>
+- (void)declaredInSuper;<br>
+<br>
+@end<br>
+<br>
+@interface NSObject (Category)<br>
+<br>
+- (void)declaredInSuperCategory;<br>
+<br>
 @end<br>
<br>
 @interface Sub: NSObject<br>
<br>
 - (instancetype)init __attribute__((unavailable)); // expected-note 4 {{'init' has been explicitly marked unavailable here}}<br>
<br>
-- (void)notImplemented __attribute__((unavailable)); // expected-note {{'notImplemented' has been explicitly marked unavailable here}}<br>
+- (void)notImplemented __attribute__((unavailable));<br>
+<br>
+- (void)declaredInSuper __attribute__((unavailable));<br>
+- (void)declaredInSuperCategory __attribute__((unavailable));<br>
<br>
 @end<br>
<br>
@@ -34,7 +45,14 @@<br>
 }<br>
<br>
 - (void)reportUseOfUnimplemented {<br>
-  [self notImplemented]; // expected-error {{'notImplemented' is unavailable}}<br>
+  [self notImplemented];<br>
+}<br>
+<br>
+- (void)allowSuperCallUsingSelf {<br>
+  [self declaredInSuper];<br>
+  [[Sub alloc] declaredInSuper];<br>
+  [self declaredInSuperCategory];<br>
+  [[Sub alloc] declaredInSuperCategory];<br>
 }<br>
<br>
 @end<br>
<br>
Modified: cfe/trunk/test/SemaObjC/infer-availability-from-init.m<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/infer-availability-from-init.m?rev=351459&r1=351458&r2=351459&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/infer-availability-from-init.m?rev=351459&r1=351458&r2=351459&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/SemaObjC/infer-availability-from-init.m (original)<br>
+++ cfe/trunk/test/SemaObjC/infer-availability-from-init.m Thu Jan 17 10:12:45 2019<br>
@@ -47,12 +47,12 @@ void usenotmyobject() {<br>
 }<br>
<br>
 @interface FromSelf : NSObject<br>
--(instancetype)init __attribute__((unavailable)); // expected-note {{'init' has been explicitly marked unavailable here}}<br>
+-(instancetype)init __attribute__((unavailable));<br>
 +(FromSelf*)another_one;<br>
 @end<br>
<br>
 @implementation FromSelf<br>
 +(FromSelf*)another_one {<br>
-  [self new]; // expected-error{{'new' is unavailable}}<br>
+  [self new];<br>
 }<br>
 @end<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div>