summaryrefslogtreecommitdiffstats
path: root/test/Analysis/self-init.m
diff options
context:
space:
mode:
Diffstat (limited to 'test/Analysis/self-init.m')
-rw-r--r--test/Analysis/self-init.m31
1 files changed, 29 insertions, 2 deletions
diff --git a/test/Analysis/self-init.m b/test/Analysis/self-init.m
index d515173..b0c51a2 100644
--- a/test/Analysis/self-init.m
+++ b/test/Analysis/self-init.m
@@ -1,7 +1,9 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=osx.cocoa.SelfInit -fobjc-default-synthesize-properties %s -verify
+// RUN: %clang_cc1 -analyze -analyzer-checker=osx.cocoa.SelfInit -fobjc-default-synthesize-properties -analyzer-ipa=dynamic -fno-builtin %s -verify
+// RUN: %clang_cc1 -analyze -analyzer-checker=osx.cocoa.SelfInit -fobjc-default-synthesize-properties -fno-builtin %s -verify
@class NSZone, NSCoder;
-@protocol NSObject- (id)self;
+@protocol NSObject
+- (id)self;
@end
@protocol NSCopying - (id)copyWithZone:(NSZone *)zone;
@end
@@ -254,3 +256,28 @@ extern id _commonInit(MyObj *self);
return self;
}
@end
+
+// Test for radar://11125870: init constructing a special instance.
+typedef signed char BOOL;
+@interface MyClass : NSObject
+@end
+@implementation MyClass
++ (id)specialInstance {
+ return [[MyClass alloc] init];
+}
+- (id)initSpecially:(BOOL)handleSpecially {
+ if ((self = [super init])) {
+ if (handleSpecially) {
+ self = [MyClass specialInstance];
+ }
+ }
+ return self;
+}
+- (id)initSelfSelf {
+ if ((self = [super init])) {
+ self = self;
+ }
+ return self;
+}
+@end
+
OpenPOWER on IntegriCloud