[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / ARCMT / Common.h
blobb388ecab741097ab5881ef4a51e85ebe85b0cef7
1 #if __has_feature(objc_arr)
2 #define NS_AUTOMATED_REFCOUNT_UNAVAILABLE __attribute__((unavailable("not available in automatic reference counting mode")))
3 #else
4 #define NS_AUTOMATED_REFCOUNT_UNAVAILABLE
5 #endif
7 #define NS_RETURNS_RETAINED __attribute__((ns_returns_retained))
8 #define CF_CONSUMED __attribute__((cf_consumed))
9 #define CF_RETURNS_RETAINED __attribute__((cf_returns_retained))
11 #define NS_INLINE static __inline__ __attribute__((always_inline))
12 #define nil ((void*) 0)
13 #define NULL ((void*)0)
15 typedef int BOOL;
16 typedef unsigned NSUInteger;
17 typedef int int32_t;
18 typedef unsigned char uint8_t;
19 typedef int32_t UChar32;
20 typedef unsigned char UChar;
22 typedef struct _NSZone NSZone;
24 typedef const void * CFTypeRef;
25 CFTypeRef CFRetain(CFTypeRef cf);
26 CFTypeRef CFMakeCollectable(CFTypeRef cf) NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
28 NS_INLINE NS_RETURNS_RETAINED id NSMakeCollectable(CFTypeRef CF_CONSUMED cf) NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
30 @protocol NSObject
31 - (BOOL)isEqual:(id)object;
32 - (NSZone *)zone NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
33 - (id)retain NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
34 - (NSUInteger)retainCount NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
35 - (oneway void)release NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
36 - (id)autorelease NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
37 @end
39 @interface NSObject <NSObject> {}
40 - (id)init;
42 + (id)new;
43 + (id)alloc;
44 - (void)dealloc;
46 - (void)finalize;
48 - (id)copy;
49 - (id)mutableCopy;
50 @end
52 NS_AUTOMATED_REFCOUNT_UNAVAILABLE
53 @interface NSAutoreleasePool : NSObject {
54 @private
55 void *_token;
56 void *_reserved3;
57 void *_reserved2;
58 void *_reserved;
61 + (void)addObject:(id)anObject;
63 - (void)addObject:(id)anObject;
65 - (void)drain;
67 @end
69 typedef const void* objc_objectptr_t;
70 extern __attribute__((ns_returns_retained)) id objc_retainedObject(objc_objectptr_t __attribute__((cf_consumed)) pointer);
71 extern __attribute__((ns_returns_not_retained)) id objc_unretainedObject(objc_objectptr_t pointer);
72 extern objc_objectptr_t objc_unretainedPointer(id object);
74 #define dispatch_retain(object) ({ dispatch_object_t _o = (object); _dispatch_object_validate(_o); (void)[_o retain]; })
75 #define dispatch_release(object) ({ dispatch_object_t _o = (object); _dispatch_object_validate(_o); [_o release]; })
76 #define xpc_retain(object) ({ xpc_object_t _o = (object); _xpc_object_validate(_o); [_o retain]; })
77 #define xpc_release(object) ({ xpc_object_t _o = (object); _xpc_object_validate(_o); [_o release]; })
79 typedef id dispatch_object_t;
80 typedef id xpc_object_t;
82 void _dispatch_object_validate(dispatch_object_t object);
83 void _xpc_object_validate(xpc_object_t object);
85 #if __has_feature(objc_arc)
87 NS_INLINE CF_RETURNS_RETAINED CFTypeRef CFBridgingRetain(id X) {
88 return (__bridge_retained CFTypeRef)X;
91 NS_INLINE id CFBridgingRelease(CFTypeRef CF_CONSUMED X) {
92 return (__bridge_transfer id)X;
95 #else
97 NS_INLINE CF_RETURNS_RETAINED CFTypeRef CFBridgingRetain(id X) {
98 return X ? CFRetain((CFTypeRef)X) : NULL;
101 NS_INLINE id CFBridgingRelease(CFTypeRef CF_CONSUMED X) {
102 return [(id)CFMakeCollectable(X) autorelease];
105 #endif
107 void *_Block_copy(const void *aBlock);
108 void _Block_release(const void *aBlock);
109 #define Block_copy(...) ((__typeof(__VA_ARGS__))_Block_copy((const void *)(__VA_ARGS__)))
110 #define Block_release(...) _Block_release((const void *)(__VA_ARGS__))