[llvm-branch-commits] [cfe-branch] r351535 - Merging r351459:
Hans Wennborg via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Jan 18 01:52:52 PST 2019
Author: hans
Date: Fri Jan 18 01:52:52 2019
New Revision: 351535
URL: http://llvm.org/viewvc/llvm-project?rev=351535&view=rev
Log:
Merging r351459:
------------------------------------------------------------------------
r351459 | arphaman | 2019-01-17 19:12:45 +0100 (Thu, 17 Jan 2019) | 13 lines
[ObjC] Follow-up r350768 and allow the use of unavailable methods that are
declared in a parent class from within the @implementation context
This commit extends r350768 and allows the use of methods marked as unavailable
that are declared in a parent class/category from within the @implementation of
the class where the method is marked as unavailable.
This allows users to call init that's marked as unavailable even if they don't
define it.
rdar://47134898
Differential Revision: https://reviews.llvm.org/D56816
------------------------------------------------------------------------
Modified:
cfe/branches/release_80/ (props changed)
cfe/branches/release_80/lib/Sema/SemaDeclAttr.cpp
cfe/branches/release_80/test/SemaObjC/call-unavailable-init-in-self.m
cfe/branches/release_80/test/SemaObjC/infer-availability-from-init.m
Propchange: cfe/branches/release_80/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Jan 18 01:52:52 2019
@@ -1,4 +1,4 @@
/cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:351334,351340,351344,351360,351457
+/cfe/trunk:351334,351340,351344,351360,351457,351459
/cfe/trunk/test:170344
/cfe/trunk/test/SemaTemplate:126920
Modified: cfe/branches/release_80/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_80/lib/Sema/SemaDeclAttr.cpp?rev=351535&r1=351534&r2=351535&view=diff
==============================================================================
--- cfe/branches/release_80/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/branches/release_80/lib/Sema/SemaDeclAttr.cpp Fri Jan 18 01:52:52 2019
@@ -7365,13 +7365,11 @@ ShouldDiagnoseAvailabilityInContext(Sema
return true;
} else if (K == AR_Unavailable) {
// It is perfectly fine to refer to an 'unavailable' Objective-C method
- // when it's actually defined and is referenced from within the
- // @implementation itself. In this context, we interpret unavailable as a
- // form of access control.
+ // when it is referenced from within the @implementation itself. In this
+ // context, we interpret unavailable as a form of access control.
if (const auto *MD = dyn_cast<ObjCMethodDecl>(OffendingDecl)) {
if (const auto *Impl = dyn_cast<ObjCImplDecl>(C)) {
- if (MD->getClassInterface() == Impl->getClassInterface() &&
- MD->isDefined())
+ if (MD->getClassInterface() == Impl->getClassInterface())
return true;
}
}
Modified: cfe/branches/release_80/test/SemaObjC/call-unavailable-init-in-self.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_80/test/SemaObjC/call-unavailable-init-in-self.m?rev=351535&r1=351534&r2=351535&view=diff
==============================================================================
--- cfe/branches/release_80/test/SemaObjC/call-unavailable-init-in-self.m (original)
+++ cfe/branches/release_80/test/SemaObjC/call-unavailable-init-in-self.m Fri Jan 18 01:52:52 2019
@@ -5,13 +5,24 @@
+ (instancetype)new;
+ (instancetype)alloc;
+- (void)declaredInSuper;
+
+ at end
+
+ at interface NSObject (Category)
+
+- (void)declaredInSuperCategory;
+
@end
@interface Sub: NSObject
- (instancetype)init __attribute__((unavailable)); // expected-note 4 {{'init' has been explicitly marked unavailable here}}
-- (void)notImplemented __attribute__((unavailable)); // expected-note {{'notImplemented' has been explicitly marked unavailable here}}
+- (void)notImplemented __attribute__((unavailable));
+
+- (void)declaredInSuper __attribute__((unavailable));
+- (void)declaredInSuperCategory __attribute__((unavailable));
@end
@@ -34,7 +45,14 @@
}
- (void)reportUseOfUnimplemented {
- [self notImplemented]; // expected-error {{'notImplemented' is unavailable}}
+ [self notImplemented];
+}
+
+- (void)allowSuperCallUsingSelf {
+ [self declaredInSuper];
+ [[Sub alloc] declaredInSuper];
+ [self declaredInSuperCategory];
+ [[Sub alloc] declaredInSuperCategory];
}
@end
Modified: cfe/branches/release_80/test/SemaObjC/infer-availability-from-init.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_80/test/SemaObjC/infer-availability-from-init.m?rev=351535&r1=351534&r2=351535&view=diff
==============================================================================
--- cfe/branches/release_80/test/SemaObjC/infer-availability-from-init.m (original)
+++ cfe/branches/release_80/test/SemaObjC/infer-availability-from-init.m Fri Jan 18 01:52:52 2019
@@ -47,12 +47,12 @@ void usenotmyobject() {
}
@interface FromSelf : NSObject
--(instancetype)init __attribute__((unavailable)); // expected-note {{'init' has been explicitly marked unavailable here}}
+-(instancetype)init __attribute__((unavailable));
+(FromSelf*)another_one;
@end
@implementation FromSelf
+(FromSelf*)another_one {
- [self new]; // expected-error{{'new' is unavailable}}
+ [self new];
}
@end
More information about the llvm-branch-commits
mailing list