summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/Analysis/superclass.m (renamed from clang/test/Analysis/viewcontroller.m)95
1 files changed, 91 insertions, 4 deletions
diff --git a/clang/test/Analysis/viewcontroller.m b/clang/test/Analysis/superclass.m
index a8c45806db1..ba5ea40aceb 100644
--- a/clang/test/Analysis/viewcontroller.m
+++ b/clang/test/Analysis/superclass.m
@@ -1,5 +1,6 @@
// RUN: %clang_cc1 -fblocks -analyze -analyzer-checker=alpha.osx.cocoa.MissingSuperCall -verify -Wno-objc-root-class %s
+// Define used Classes
@protocol NSObject
- (id)retain;
- (oneway void)release;
@@ -8,13 +9,15 @@
- (id)init;
+ (id)alloc;
@end
-
typedef char BOOL;
typedef double NSTimeInterval;
typedef enum UIViewAnimationOptions {
UIViewAnimationOptionLayoutSubviews = 1 << 0
} UIViewAnimationOptions;
+@interface NSCoder : NSObject {}
+@end
+// Define the Superclasses for our Checks
@interface UIViewController : NSObject {}
- (void)addChildViewController:(UIViewController *)childController;
- (void)viewDidAppear:(BOOL)animated;
@@ -32,8 +35,21 @@ typedef enum UIViewAnimationOptions {
animations:(void (^)(void))animations
completion:(void (^)(BOOL finished))completion;
@end
+@interface UIResponder : NSObject {}
+- (BOOL)resignFirstResponder;
+@end
+@interface NSResponder : NSObject {}
+- (void)restoreStateWithCoder:(NSCoder *)coder;
+- (void)encodeRestorableStateWithCoder:(NSCoder *)coder;
+@end
+@interface NSDocument : NSObject {}
+- (void)restoreStateWithCoder:(NSCoder *)coder;
+- (void)encodeRestorableStateWithCoder:(NSCoder *)coder;
+@end
-// Do not warn if UIViewController isn't our superclass
+// Checks
+
+// Do not warn if UIViewController/*Responder/NSDocument is not our superclass
@interface TestA
@end
@implementation TestA
@@ -48,7 +64,9 @@ typedef enum UIViewAnimationOptions {
- (void)viewWillDisappear:(BOOL)animated {}
- (void)didReceiveMemoryWarning {}
- (void)removeFromParentViewController {}
-
+- (BOOL)resignFirstResponder { return 0; }
+- (void)restoreStateWithCoder:(NSCoder *)coder {}
+- (void)encodeRestorableStateWithCoder:(NSCoder *)coder {}
@end
// Warn if UIViewController is our superclass and we do not call super
@@ -72,7 +90,7 @@ typedef enum UIViewAnimationOptions {
- (void)removeFromParentViewController {} // expected-warning {{The 'removeFromParentViewController' instance method in UIViewController subclass 'TestB' is missing a [super removeFromParentViewController] call}}
// Do not warn for methods were it shouldn't
-- (void)shouldAutorotate {};
+- (void)shouldAutorotate {}
@end
// Do not warn if UIViewController is our superclass but we did call super
@@ -133,3 +151,72 @@ typedef enum UIViewAnimationOptions {
[self methodDoingStuff];
} // expected-warning {{The 'removeFromParentViewController' instance method in UIViewController subclass 'TestC' is missing a [super removeFromParentViewController] call}}
@end
+
+
+// Do warn for UIResponder subclasses that don't call super
+@interface TestD : UIResponder {}
+@end
+@implementation TestD
+
+- (BOOL)resignFirstResponder {
+ return 0;
+} // expected-warning {{The 'resignFirstResponder' instance method in UIResponder subclass 'TestD' is missing a [super resignFirstResponder] call}}
+@end
+
+// Do not warn for UIResponder subclasses that do the right thing
+@interface TestE : UIResponder {}
+@end
+@implementation TestE
+
+- (BOOL)resignFirstResponder {
+ return [super resignFirstResponder];
+}
+@end
+
+// Do warn for NSResponder subclasses that don't call super
+@interface TestF : NSResponder {}
+@end
+@implementation TestF
+
+- (void)restoreStateWithCoder:(NSCoder *)coder {
+} // expected-warning {{The 'restoreStateWithCoder:' instance method in NSResponder subclass 'TestF' is missing a [super restoreStateWithCoder:] call}}
+- (void)encodeRestorableStateWithCoder:(NSCoder *)coder {
+} // expected-warning {{The 'encodeRestorableStateWithCoder:' instance method in NSResponder subclass 'TestF' is missing a [super encodeRestorableStateWithCoder:] call}}
+@end
+
+// Do not warn for NSResponder subclasses that do the right thing
+@interface TestG : NSResponder {}
+@end
+@implementation TestG
+
+- (void)restoreStateWithCoder:(NSCoder *)coder {
+ [super restoreStateWithCoder:coder];
+}
+- (void)encodeRestorableStateWithCoder:(NSCoder *)coder {
+ [super encodeRestorableStateWithCoder:coder];
+}
+@end
+
+// Do warn for NSDocument subclasses that don't call super
+@interface TestH : NSDocument {}
+@end
+@implementation TestH
+
+- (void)restoreStateWithCoder:(NSCoder *)coder {
+} // expected-warning {{The 'restoreStateWithCoder:' instance method in NSDocument subclass 'TestH' is missing a [super restoreStateWithCoder:] call}}
+- (void)encodeRestorableStateWithCoder:(NSCoder *)coder {
+} // expected-warning {{The 'encodeRestorableStateWithCoder:' instance method in NSDocument subclass 'TestH' is missing a [super encodeRestorableStateWithCoder:] call}}
+@end
+
+// Do not warn for NSDocument subclasses that do the right thing
+@interface TestI : NSDocument {}
+@end
+@implementation TestI
+
+- (void)restoreStateWithCoder:(NSCoder *)coder {
+ [super restoreStateWithCoder:coder];
+}
+- (void)encodeRestorableStateWithCoder:(NSCoder *)coder {
+ [super encodeRestorableStateWithCoder:coder];
+}
+@end \ No newline at end of file
OpenPOWER on IntegriCloud