Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / tools / clang-fuzzer / corpus_examples / objc / SharedInstance.m
blob282baffc58fb6239356d0a78eee800bd0a10c898
1 @interface RootObject
2 + (instancetype)alloc;
4 - (instancetype)init;
5 @end
7 @interface BaseClass : RootObject
8 + (instancetype)sharedInstance;
10 - (instancetype)initWithFoo:(int)foo;
11 @end
13 static BaseClass *sharedInstance = (void *)0;
14 static int counter = 0;
16 @implementation BaseClass
17 + (instancetype)sharedInstance {
18   if (sharedInstance) {
19     return sharedInstance;
20   }
21   sharedInstance = [[BaseClass alloc] initWithFoo:3];
22   return sharedInstance;
26 - (instancetype)initWithFoo:(int)foo {
27   self = [super init];
28   if (self) {
29     counter += foo;
30   }
31   return self;
33 @end