[PATCH] D56469: [ObjC] Allow the use of implemented unavailable methods from within the @implementation context
Erik Pilkington via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 9 10:22:38 PST 2019
erik.pilkington added inline comments.
================
Comment at: lib/Sema/SemaDeclAttr.cpp:7290
+ // when it's actually defined and is referenced from within the
+ // @implementation itself.
+ if (const auto *MD = dyn_cast<ObjCMethodDecl>(OffendingDecl)) {
----------------
Maybe add a sentence: In this context, we interpret unavailable as a form of access control.
================
Comment at: lib/Sema/SemaDeclAttr.cpp:7292
+ if (const auto *MD = dyn_cast<ObjCMethodDecl>(OffendingDecl)) {
+ if (const auto *Impl = dyn_cast<ObjCImplDecl>(Ctx)) {
+ if (MD->getClassInterface() == Impl->getClassInterface() &&
----------------
This should be `C` instead of `Ctx` right? Sorry, the naming here really sucks.
================
Comment at: test/SemaObjC/call-unavailable-init-in-self.m:57
+ (void)[Sub new]; // expected-error {{'new' is unavailable}}
+}
----------------
Can you add a test for category implementations:
```
@interface X @end
@interface X (Foo)
-(void)meth __attribute__((unavailable))
@end
@implementation X (Foo)
-(void)meth {}
-(void)call_it { [self meth]; }
@end
```
Repository:
rC Clang
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D56469/new/
https://reviews.llvm.org/D56469
More information about the cfe-commits
mailing list