[cfe-commits] r163525 - in /cfe/trunk: lib/Sema/SemaDeclObjC.cpp test/SemaObjC/super-dealloc-attribute.m
Fariborz Jahanian
fjahanian at apple.com
Mon Sep 10 11:04:25 PDT 2012
Author: fjahanian
Date: Mon Sep 10 13:04:25 2012
New Revision: 163525
URL: http://llvm.org/viewvc/llvm-project?rev=163525&view=rev
Log:
More tweaking and test cases for call to super
annotations. // rdar://6386358
Modified:
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/test/SemaObjC/super-dealloc-attribute.m
Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=163525&r1=163524&r2=163525&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Mon Sep 10 13:04:25 2012
@@ -388,9 +388,12 @@
!(Context.getLangOpts().ObjCAutoRefCount ||
Context.getLangOpts().getGC() == LangOptions::GCOnly) &&
MDecl->getMethodFamily() == OMF_dealloc;
- if (!getCurFunction()->ObjCShouldCallSuperDealloc)
+ if (!getCurFunction()->ObjCShouldCallSuperDealloc) {
+ IMD = IC->getSuperClass()->lookupMethod(MDecl->getSelector(),
+ MDecl->isInstanceMethod());
getCurFunction()->ObjCShouldCallSuperDealloc =
(IMD && IMD->hasAttr<ObjCRequiresSuperAttr>());
+ }
getCurFunction()->ObjCShouldCallSuperFinalize =
Context.getLangOpts().getGC() != LangOptions::NonGC &&
MDecl->getMethodFamily() == OMF_finalize;
Modified: cfe/trunk/test/SemaObjC/super-dealloc-attribute.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/super-dealloc-attribute.m?rev=163525&r1=163524&r2=163525&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/super-dealloc-attribute.m (original)
+++ cfe/trunk/test/SemaObjC/super-dealloc-attribute.m Mon Sep 10 13:04:25 2012
@@ -2,20 +2,30 @@
// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify -Wno-objc-root-class %s
// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -verify -Wno-objc-root-class %s
// RUN: %clang_cc1 -x objective-c++ -fobjc-arc -fsyntax-only -verify -Wno-objc-root-class %s
-
// rdar://6386358
+
+#if __has_attribute(objc_requires_super)
+#define NS_REQUIRES_SUPER __attribute((objc_requires_super))
+#endif
+
@protocol NSObject // expected-note {{protocol is declared here}}
-- MyDealloc __attribute((objc_requires_super)); // expected-warning {{'objc_requires_super' attribute cannot be applied to methods in protocols}}
+- MyDealloc NS_REQUIRES_SUPER; // expected-warning {{'objc_requires_super' attribute cannot be applied to methods in protocols}}
@end
@interface Root
- MyDealloc __attribute((objc_requires_super));
- (void)XXX __attribute((objc_requires_super));
- (void) dealloc __attribute((objc_requires_super)); // expected-warning {{'objc_requires_super' attribute cannot be applied to dealloc}}
+- (void) MyDeallocMeth; // Method in root is not annotated.
+- (void) AnnotMyDeallocMeth __attribute((objc_requires_super));
+- (void) AnnotMyDeallocMethCAT NS_REQUIRES_SUPER;
@end
@interface Baz : Root<NSObject>
- MyDealloc;
+- (void) MyDeallocMeth __attribute((objc_requires_super)); // 'Baz' author has annotated method
+- (void) AnnotMyDeallocMeth; // Annotated in root but not here. Annotation is inherited though
+- (void) AnnotMeth __attribute((objc_requires_super)); // 'Baz' author has annotated method
@end
@implementation Baz
@@ -27,5 +37,30 @@
- (void)XXX {
[super MyDealloc];
} // expected-warning {{method possibly missing a [super XXX] call}}
+
+- (void) MyDeallocMeth {} // No warning here.
+- (void) AnnotMyDeallocMeth{} // expected-warning {{method possibly missing a [super AnnotMyDeallocMeth] call}}
+- (void) AnnotMeth{}; // No warning here. Annotation is in its class.
+ at end
+
+ at interface Bar : Baz
@end
+ at implementation Bar
+- (void) MyDeallocMeth {} // expected-warning {{method possibly missing a [super MyDeallocMeth] call}}
+- (void) AnnotMyDeallocMeth{} // expected-warning {{method possibly missing a [super AnnotMyDeallocMeth] call}}
+- (void) AnnotMeth{}; // expected-warning {{method possibly missing a [super AnnotMeth] call}}
+ at end
+
+ at interface Bar(CAT)
+- (void) AnnotMyDeallocMethCAT; // Annotated in root but not here. Annotation is inherited though
+- (void) AnnotMethCAT __attribute((objc_requires_super));
+ at end
+
+ at implementation Bar(CAT)
+- (void) MyDeallocMeth {} // expected-warning {{method possibly missing a [super MyDeallocMeth] call}}
+- (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 {};
+ at end
More information about the cfe-commits
mailing list