blob: 8048e06748aa2383a2ea062142c2a4ebb72c06bb [file] [log] [blame]
Fariborz Jahanian8a6ad2a2013-08-30 23:52:08 +00001// RUN: rm -rf %t
Fariborz Jahaniancd569f22013-11-05 22:28:30 +00002// RUN: %clang_cc1 -objcmt-returns-innerpointer-property -objcmt-migrate-annotation -objcmt-migrate-readwrite-property -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11
Fariborz Jahanian8a6ad2a2013-08-30 23:52:08 +00003// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
Rafael Espindola14f98892013-09-27 20:21:48 +00004// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result
Fariborz Jahanian8a6ad2a2013-08-30 23:52:08 +00005
6#ifndef NS_RETURNS_INNER_POINTER // defined in iOS 6 for sure
7#define NS_RETURNS_INNER_POINTER __attribute__((objc_returns_inner_pointer))
8#endif
9
10#define CF_IMPLICIT_BRIDGING_ENABLED _Pragma("clang arc_cf_code_audited begin")
11
12#define CF_IMPLICIT_BRIDGING_DISABLED _Pragma("clang arc_cf_code_audited end")
13
14#if __has_feature(attribute_ns_returns_retained)
15#define NS_RETURNS_RETAINED __attribute__((ns_returns_retained))
16#endif
17#if __has_feature(attribute_cf_returns_retained)
18#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained))
19#endif
20#if __has_feature(attribute_ns_returns_not_retained)
21#define NS_RETURNS_NOT_RETAINED __attribute__((ns_returns_not_retained))
22#endif
23#if __has_feature(attribute_cf_returns_not_retained)
24#define CF_RETURNS_NOT_RETAINED __attribute__((cf_returns_not_retained))
25#endif
26#if __has_feature(attribute_ns_consumes_self)
27#define NS_CONSUMES_SELF __attribute__((ns_consumes_self))
28#endif
29#if __has_feature(attribute_ns_consumed)
30#define NS_CONSUMED __attribute__((ns_consumed))
31#endif
32#if __has_feature(attribute_cf_consumed)
33#define CF_CONSUMED __attribute__((cf_consumed))
34#endif
35#if __has_attribute(ns_returns_autoreleased)
36#define NS_RETURNS_AUTORELEASED __attribute__((ns_returns_autoreleased))
37#endif
38
Fariborz Jahanianf85f5e42013-09-24 20:20:52 +000039#define NS_AVAILABLE __attribute__((availability(macosx,introduced=10.0)))
40
Fariborz Jahanian8a6ad2a2013-08-30 23:52:08 +000041CF_IMPLICIT_BRIDGING_ENABLED
42
43typedef unsigned long CFTypeID;
44typedef unsigned long CFOptionFlags;
45typedef unsigned long CFHashCode;
46
47typedef signed long CFIndex; /*AnyObj*/
48typedef const struct __CFArray * CFArrayRef;
49typedef struct {
50 CFIndex location;
51 CFIndex length;
52} CFRange;
53
54typedef void (*CFArrayApplierFunction)(const void *value, void *context);
55
56typedef enum CFComparisonResult : CFIndex CFComparisonResult; enum CFComparisonResult : CFIndex {
57 kCFCompareLessThan = -1L,
58 kCFCompareEqualTo = 0,
59 kCFCompareGreaterThan = 1
60};
61
62
63typedef CFComparisonResult (*CFComparatorFunction)(const void *val1, const void *val2, void *context);
64
65typedef struct __CFArray * CFMutableArrayRef;
66
67typedef const struct __CFAttributedString *CFAttributedStringRef;
68typedef struct __CFAttributedString *CFMutableAttributedStringRef;
69
70typedef const struct __CFAllocator * CFAllocatorRef;
71
72typedef const struct __CFString * CFStringRef;
73typedef struct __CFString * CFMutableStringRef;
74
75typedef const struct __CFDictionary * CFDictionaryRef;
76typedef struct __CFDictionary * CFMutableDictionaryRef;
77
78typedef struct CGImage *CGImageRef;
79
Fariborz Jahanianc72b4b32013-09-09 23:56:14 +000080typedef struct OpaqueJSValue* JSObjectRef;
81
82typedef JSObjectRef TTJSObjectRef;
Fariborz Jahanian3226abf2013-09-24 20:31:24 +000083typedef unsigned int NSUInteger;
Fariborz Jahanianc72b4b32013-09-09 23:56:14 +000084
Fariborz Jahanian8a6ad2a2013-08-30 23:52:08 +000085CF_IMPLICIT_BRIDGING_DISABLED
86
87@interface I
88- (void*) ReturnsInnerPointer NS_RETURNS_INNER_POINTER;
89- (int*) AlreadyReturnsInnerPointer NS_RETURNS_INNER_POINTER;
90@end
91
92@interface UIImage
Fariborz Jahanian5f7ac672013-09-04 00:10:06 +000093- (CGImageRef)CGImage CF_RETURNS_NOT_RETAINED;
Fariborz Jahanian8a6ad2a2013-08-30 23:52:08 +000094@end
95
96@interface NSData
97- (void *)bytes NS_RETURNS_INNER_POINTER;
98- (void **) ptr_bytes __attribute__((availability(macosx,unavailable))) NS_RETURNS_INNER_POINTER;
99@end
100
101@interface NSMutableData
102- (void *)mutableBytes __attribute__((deprecated)) __attribute__((unavailable)) NS_RETURNS_INNER_POINTER;
103@end
Fariborz Jahanianc72b4b32013-09-09 23:56:14 +0000104
105@interface JS
106- (JSObjectRef)JSObject;
107- (TTJSObjectRef)JSObject1;
108- (JSObjectRef*)JSObject2 NS_RETURNS_INNER_POINTER;
109@end
Fariborz Jahanianf85f5e42013-09-24 20:20:52 +0000110
111// rdar://15044991
112typedef void *SecTrustRef;
113
114@interface NSURLProtectionSpace
115@property (readonly) SecTrustRef NS_RETURNS_INNER_POINTER serverTrust NS_AVAILABLE;
116- (void *) FOO NS_AVAILABLE NS_RETURNS_INNER_POINTER;
117@property (readonly) void * NS_RETURNS_INNER_POINTER mitTrust NS_AVAILABLE;
118
119@property (readonly) void * NS_RETURNS_INNER_POINTER mittiTrust;
120
121@property (readonly) SecTrustRef NS_RETURNS_INNER_POINTER XserverTrust;
122
123- (SecTrustRef) FOO1 NS_AVAILABLE NS_RETURNS_INNER_POINTER;
124
Fariborz Jahanianf1ebccd2013-09-26 22:43:41 +0000125+ (const NSURLProtectionSpace *)ProtectionSpace;
126
Fariborz Jahanian3226abf2013-09-24 20:31:24 +0000127// pointer personality functions
Fariborz Jahanian0d4e0682013-09-26 21:43:47 +0000128@property NSUInteger (*hashFunction)(const void *item, NSUInteger (*size)(const void *item));
Fariborz Jahanianf85f5e42013-09-24 20:20:52 +0000129@end