From: Fariborz Jahanian <fjahanian@apple.com> Date: Tue, 5 Nov 2013 00:28:21 +0000 (+0000) Subject: ObjectiveC. Method implementations should only check for X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2b61039ceb9162e7b47ed4cb92b957c8a7668da1;p=clang ObjectiveC. Method implementations should only check for "Missing call to Super" in the overriding method and not in the method itself. // rdar://15385981. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194031 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index be78767510..86979a1fe8 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -406,9 +406,7 @@ void Sema::ActOnStartOfObjCMethodDef(Scope *FnBodyScope, Decl *D) { if (Context.getLangOpts().getGC() != LangOptions::NonGC) getCurFunction()->ObjCShouldCallSuper = true; - } else if (MDecl->hasAttr<ObjCRequiresSuperAttr>()) - getCurFunction()->ObjCShouldCallSuper = true; - else { + } else { const ObjCMethodDecl *SuperMethod = SuperClass->lookupMethod(MDecl->getSelector(), MDecl->isInstanceMethod()); diff --git a/test/SemaObjC/super-dealloc-attribute.m b/test/SemaObjC/super-dealloc-attribute.m index 911de73266..ecab109d30 100644 --- a/test/SemaObjC/super-dealloc-attribute.m +++ b/test/SemaObjC/super-dealloc-attribute.m @@ -40,9 +40,9 @@ [super MyDealloc]; } // expected-warning {{method possibly missing a [super XXX] call}} -- (void) MyDeallocMeth {} // expected-warning {{method possibly missing a [super MyDeallocMeth] call}} +- (void) MyDeallocMeth {} - (void) AnnotMyDeallocMeth{} // expected-warning {{method possibly missing a [super AnnotMyDeallocMeth] call}} -- (void) AnnotMeth{}; // expected-warning {{method possibly missing a [super AnnotMeth] call}} +- (void) AnnotMeth{}; + (void)registerClass:(id)name {} // expected-warning {{method possibly missing a [super registerClass:] call}} @end @@ -66,7 +66,7 @@ - (void) AnnotMyDeallocMeth{} // expected-warning {{method possibly missing a [super AnnotMyDeallocMeth] call}} - (void) AnnotMeth{}; // expected-warning {{method possibly missing a [super AnnotMeth] call}} - (void) AnnotMyDeallocMethCAT{}; // expected-warning {{method possibly missing a [super AnnotMyDeallocMethCAT] call}} -- (void) AnnotMethCAT {}; // expected-warning {{method possibly missing a [super AnnotMethCAT] call}} +- (void) AnnotMethCAT {}; @end @@ -101,11 +101,32 @@ @implementation ViewController - (void) someMethodRequiringSuper { -} // expected-warning {{method possibly missing a [super someMethodRequiringSuper] call}} +} - (IBAction) someAction { } - (IBAction) someActionRequiringSuper { -} // expected-warning {{method possibly missing a [super someActionRequiringSuper] call}} +} +@end + +// rdar://15385981 +@interface Barn +- (void)openDoor __attribute__((objc_requires_super)); +@end + +@implementation Barn +- (void) openDoor +{ + ; +} +@end + +@interface HorseBarn:Barn @end + +@implementation HorseBarn +- (void) openDoor +{ + ; +} // expected-warning {{method possibly missing a [super openDoor] call}} @end