xref: /aosp_15_r20/external/clang/test/Analysis/rdar-6562655.m (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core -analyzer-constraints=range -analyzer-store=region -verify %s
2*67e74705SXin Li// expected-no-diagnostics
3*67e74705SXin Li//
4*67e74705SXin Li// This test case mainly checks that the retain/release checker doesn't crash
5*67e74705SXin Li// on this file.
6*67e74705SXin Li//
7*67e74705SXin Litypedef int int32_t;
8*67e74705SXin Litypedef signed char BOOL;
9*67e74705SXin Litypedef long NSInteger;
10*67e74705SXin Litypedef unsigned long NSUInteger;
11*67e74705SXin Litypedef struct _NSZone NSZone;
12*67e74705SXin Li@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
13*67e74705SXin Li@protocol NSObject  - (BOOL)isEqual:(id)object;
14*67e74705SXin Li@end  @protocol NSCopying  - (id)copyWithZone:(NSZone *)zone;
15*67e74705SXin Li@end  @protocol NSCoding  - (void)encodeWithCoder:(NSCoder *)aCoder;
16*67e74705SXin Li@end    @interface NSObject <NSObject> {}
17*67e74705SXin Li@end      extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);
18*67e74705SXin Li@interface NSResponder : NSObject <NSCoding> {}
19*67e74705SXin Li@end    @protocol NSAnimatablePropertyContainer      - (id)animator;
20*67e74705SXin Li@end  extern NSString *NSAnimationTriggerOrderIn ;
21*67e74705SXin Li@interface NSView : NSResponder  <NSAnimatablePropertyContainer>  {
22*67e74705SXin Li}
23*67e74705SXin Li@end    enum {
24*67e74705SXin LiNSNullCellType = 0,     NSTextCellType = 1,     NSImageCellType = 2 };
25*67e74705SXin Litypedef struct __CFlags {
26*67e74705SXin Li  unsigned int botnet:3;
27*67e74705SXin Li}
28*67e74705SXin Li  _CFlags;
29*67e74705SXin Li@interface Bar : NSObject <NSCopying, NSCoding> {
30*67e74705SXin Li  _CFlags _cFlags;
31*67e74705SXin Li@private       id _support;
32*67e74705SXin Li}
33*67e74705SXin Li@end  extern NSString *NSControlTintDidChangeNotification;
34*67e74705SXin Litypedef NSInteger NSBotnet;
35*67e74705SXin Li@interface NSControl : NSView {
36*67e74705SXin Li}
37*67e74705SXin Li@end @class NSAttributedString, NSFont, NSImage, NSSound;
38*67e74705SXin Litypedef int32_t Baz;
39*67e74705SXin Li@interface Bar(BarInternal) - (void)_setIsWhite:(BOOL)isWhite;
40*67e74705SXin Li@end
41*67e74705SXin Li@interface Bar (BarBotnetCompatibility)
42*67e74705SXin Li- (NSBotnet)_initialBotnetZorg;
43*67e74705SXin Li@end
44*67e74705SXin Litypedef struct _NSRunArrayItem {
45*67e74705SXin Li  unsigned int botnetIsSet:1;
46*67e74705SXin Li} BarAuxFlags;
47*67e74705SXin Li@interface BarAuxiliary : NSObject {
48*67e74705SXin Li@public
49*67e74705SXin Li  NSControl *controlView;
50*67e74705SXin Li  BarAuxFlags auxCFlags;
51*67e74705SXin Li}
52*67e74705SXin Li@end
53*67e74705SXin Li@implementation Bar
54*67e74705SXin Listatic Baz Qux = 0;
55*67e74705SXin Li- (id)copyWithZone:(NSZone *)zone { return 0; }
56*67e74705SXin Li- (void)encodeWithCoder:(NSCoder *)coder {}
57*67e74705SXin Li@end
58*67e74705SXin Li@implementation Bar (BarBotnet)
59*67e74705SXin Li- (NSBotnet)botnet {
60*67e74705SXin Li  if (!(*(BarAuxiliary **)&self->_support)->auxCFlags.botnetIsSet) {
61*67e74705SXin Li    _cFlags.botnet = [self _initialBotnetZorg];
62*67e74705SXin Li  }
63*67e74705SXin Li  while (1) {}
64*67e74705SXin Li}
65*67e74705SXin Li@end
66