1// RUN: rm -rf %t
2// RUN: %clang_cc1 -objcmt-migrate-ns-macros -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11
3// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
4// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result
5
6typedef signed char int8_t;
7typedef short int16_t;
8typedef int int32_t;
9typedef long NSInteger;
10typedef long long int64_t;
11
12typedef unsigned char uint8_t;
13typedef unsigned short uint16_t;
14typedef unsigned int uint32_t;
15typedef unsigned long NSUInteger;
16typedef unsigned long long uint64_t;
17
18#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
19#define NS_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type
20#define DEPRECATED  __attribute__((deprecated))
21
22enum {
23  blah,
24  blarg
25};
26typedef NSInteger wibble;
27
28enum {
29    UIViewAutoresizingNone                 = 0,
30    UIViewAutoresizingFlexibleLeftMargin,
31    UIViewAutoresizingFlexibleWidth,
32    UIViewAutoresizingFlexibleRightMargin,
33    UIViewAutoresizingFlexibleTopMargin,
34    UIViewAutoresizingFlexibleHeight,
35    UIViewAutoresizingFlexibleBottomMargin
36};
37typedef NSUInteger UITableViewCellStyle;
38
39typedef enum {
40    UIViewAnimationTransitionNone,
41    UIViewAnimationTransitionFlipFromLeft,
42    UIViewAnimationTransitionFlipFromRight,
43    UIViewAnimationTransitionCurlUp,
44    UIViewAnimationTransitionCurlDown,
45} UIViewAnimationTransition;
46
47typedef enum {
48    UIViewOne   = 0,
49    UIViewTwo   = 1 << 0,
50    UIViewThree = 1 << 1,
51    UIViewFour  = 1 << 2,
52    UIViewFive  = 1 << 3,
53    UIViewSix   = 1 << 4,
54    UIViewSeven = 1 << 5
55} UITableView;
56
57enum {
58  UIOne = 0,
59  UITwo = 0x1,
60  UIthree = 0x8,
61  UIFour = 0x100
62};
63typedef NSInteger UI;
64
65typedef enum {
66  UIP2One = 0,
67  UIP2Two = 0x1,
68  UIP2three = 0x8,
69  UIP2Four = 0x100
70} UIPOWER2;
71
72enum {
73  UNOne,
74  UNTwo
75};
76
77// Should use NS_ENUM even though it is all power of 2.
78enum {
79  UIKOne = 1,
80  UIKTwo = 2,
81};
82typedef NSInteger UIK;
83
84typedef enum  {
85    NSTickMarkBelow = 0,
86    NSTickMarkAbove = 1,
87    NSTickMarkLeft = NSTickMarkAbove,
88    NSTickMarkRight = NSTickMarkBelow
89} NSTickMarkPosition;
90
91enum {
92    UIViewNone         = 0x0,
93    UIViewMargin       = 0x1,
94    UIViewWidth        = 0x2,
95    UIViewRightMargin  = 0x3,
96    UIViewBottomMargin = 0xbadbeef
97};
98typedef NSInteger UITableStyle;
99
100enum {
101    UIView0         = 0,
102    UIView1 = 0XBADBEEF
103};
104typedef NSInteger UIStyle;
105
106enum {
107    NSTIFFFileType,
108    NSBMPFileType,
109    NSGIFFileType,
110    NSJPEGFileType,
111    NSPNGFileType,
112    NSJPEG2000FileType
113};
114typedef NSUInteger NSBitmapImageFileType;
115
116enum {
117    NSWarningAlertStyle = 0,
118    NSInformationalAlertStyle = 1,
119    NSCriticalAlertStyle = 2
120};
121typedef NSUInteger NSAlertStyle;
122
123enum {
124    D_NSTIFFFileType,
125    D_NSBMPFileType,
126    D_NSGIFFileType,
127    D_NSJPEGFileType,
128    D_NSPNGFileType,
129    D_NSJPEG2000FileType
130};
131typedef NSUInteger D_NSBitmapImageFileType DEPRECATED;
132
133typedef enum  {
134    D_NSTickMarkBelow = 0,
135    D_NSTickMarkAbove = 1
136} D_NSTickMarkPosition DEPRECATED;
137
138
139#define NS_ENUM_AVAILABLE(X,Y)
140
141enum {
142    NSFStrongMemory NS_ENUM_AVAILABLE(10_5, 6_0) = (0UL << 0),
143    NSFOpaqueMemory NS_ENUM_AVAILABLE(10_5, 6_0) = (2UL << 0),
144    NSFMallocMemory NS_ENUM_AVAILABLE(10_5, 6_0) = (3UL << 0),
145    NSFMachVirtualMemory NS_ENUM_AVAILABLE(10_5, 6_0) = (4UL << 0),
146    NSFWeakMemory NS_ENUM_AVAILABLE(10_8, 6_0) = (5UL << 0),
147
148    NSFObjectPersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (0UL << 8),
149    NSFOpaquePersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (1UL << 8),
150    NSFObjectPointerPersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (2UL << 8),
151    NSFCStringPersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (3UL << 8),
152    NSFStructPersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (4UL << 8),
153    NSFIntegerPersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (5UL << 8),
154    NSFCopyIn NS_ENUM_AVAILABLE(10_5, 6_0) = (1UL << 16),
155};
156
157typedef NSUInteger NSFOptions;
158
159typedef enum {
160  UIP0One = 0,
161  UIP0Two = 1,
162  UIP0Three = 2,
163  UIP0Four = 10,
164  UIP0Last = 0x100
165} UIP;
166
167typedef enum {
168  UIPZero = 0x0,
169  UIPOne = 0x1,
170  UIPTwo = 0x2,
171  UIP10 = 0x10,
172  UIPHundred = 0x100
173} UIP_3;
174
175typedef enum {
176  UIP4Zero = 0x0,
177  UIP4One = 0x1,
178  UIP4Two = 0x2,
179  UIP410 = 0x10,
180  UIP4Hundred = 100
181} UIP4_3;
182
183typedef enum {
184  UIP5Zero = 0x0,
185  UIP5Two = 0x2,
186  UIP510 = 0x3,
187  UIP5Hundred = 0x4
188} UIP5_3;
189
190typedef enum {
191  UIP6Zero = 0x0,
192  UIP6One = 0x1,
193  UIP6Two = 0x2,
194  UIP610 = 10,
195  UIP6Hundred = 0x100
196} UIP6_3;
197
198typedef enum {
199  UIP7Zero = 0x0,
200  UIP7One = 1,
201  UIP7Two = 0x2,
202  UIP710 = 10,
203  UIP7Hundred = 100
204} UIP7_3;
205
206
207typedef enum {
208  Random = 0,
209  Random1 = 2,
210  Random2 = 4,
211  Random3 = 0x12345,
212  Random4 = 0x3444444,
213  Random5 = 0xbadbeef,
214  Random6
215} UIP8_3;
216
217// rdar://15200602
218#define NS_AVAILABLE_MAC(X)  __attribute__((availability(macosx,introduced=X)))
219#define NS_ENUM_AVAILABLE_MAC(X) __attribute__((availability(macosx,introduced=X)))
220
221enum {
222    NSModalResponseStop                 = (-1000), // Also used as the default response for sheets
223    NSModalResponseAbort                = (-1001),
224    NSModalResponseContinue             = (-1002),
225} NS_ENUM_AVAILABLE_MAC(10.9);
226typedef NSInteger NSModalResponse NS_AVAILABLE_MAC(10.9);
227
228// rdar://15201056
229typedef NSUInteger FarFarAwayOptions;
230
231// rdar://15200915
232typedef NSUInteger FarAwayOptions;
233enum {
234     NSWorkspaceLaunchAndPrint =                 0x00000002,
235     NSWorkspaceLaunchWithErrorPresentation    = 0x00000040,
236     NSWorkspaceLaunchInhibitingBackgroundOnly = 0x00000080,
237     NSWorkspaceLaunchWithoutAddingToRecents   = 0x00000100,
238     NSWorkspaceLaunchWithoutActivation        = 0x00000200,
239     NSWorkspaceLaunchAsync                    = 0x00010000,
240     NSWorkspaceLaunchAllowingClassicStartup   = 0x00020000,
241     NSWorkspaceLaunchPreferringClassic        = 0x00040000,
242     NSWorkspaceLaunchNewInstance              = 0x00080000,
243     NSWorkspaceLaunchAndHide                  = 0x00100000,
244     NSWorkspaceLaunchAndHideOthers            = 0x00200000,
245     NSWorkspaceLaunchDefault = NSWorkspaceLaunchAsync |
246     NSWorkspaceLaunchAllowingClassicStartup
247};
248typedef NSUInteger NSWorkspaceLaunchOptions;
249
250enum {
251    NSExcludeQuickDrawElementsIconCreationOption    = 1 << 1,
252    NSExclude10_4ElementsIconCreationOption         = 1 << 2
253};
254typedef NSUInteger NSExcludeOptions;
255
256enum {
257    NSExcludeQuickDrawElementsCreationOption    = 1 << 1,
258    NSExclude10_4ElementsCreationOption         = 1 << 2
259};
260typedef NSUInteger NSExcludeCreationOption;
261
262enum {
263  FarAway1    = 1 << 1,
264  FarAway2    = 1 << 2
265};
266
267enum {
268    NSExcludeQuickDrawElementsIconOption    = 1 << 1,
269    NSExclude10_4ElementsIconOption         = 1 << 2
270};
271typedef NSUInteger NSExcludeIconOptions;
272
273@interface INTF {
274  NSExcludeIconOptions I1;
275  NSExcludeIconOptions I2;
276}
277@end
278
279enum {
280  FarFarAway1    = 1 << 1,
281  FarFarAway2    = 1 << 2
282};
283
284// rdar://15200915
285typedef NS_OPTIONS(NSUInteger, NSWindowOcclusionState) {
286    NSWindowOcclusionStateVisible = 1UL << 1,
287};
288
289typedef NSUInteger NSWindowNumberListOptions;
290
291enum {
292    NSDirectSelection = 0,
293    NSSelectingNext,
294    NSSelectingPrevious
295};
296typedef NSUInteger NSSelectionDirection;
297
298// standard window buttons
299enum {
300    NSWindowCloseButton,
301    NSWindowMiniaturizeButton,
302    NSWindowZoomButton,
303    NSWindowToolbarButton,
304    NSWindowDocumentIconButton
305};
306
307// rdar://18262255
308typedef enum : NSUInteger {
309   ThingOne,
310   ThingTwo,
311   ThingThree,
312} Thing;
313
314// rdar://18498539
315typedef enum {
316    one = 1
317} NumericEnum;
318
319typedef enum {
320    Two = 2
321}NumericEnum2;
322
323typedef enum {
324    Three = 3
325}
326NumericEnum3;
327
328typedef enum {
329    Four = 4
330}
331
332  NumericEnum4;
333
334// rdar://18532199
335enum
336{
337  UI8one = 1
338};
339typedef int8_t MyEnumeratedType;
340
341
342enum {
343  UI16One = 0,
344  UI16Two = 0x1,
345  UI16three = 0x8,
346  UI16Four = 0x100
347};
348typedef int16_t UI16;
349
350enum {
351    UI32ViewAutoresizingNone                 = 0,
352    UI32ViewAutoresizingFlexibleLeftMargin,
353    UI32ViewAutoresizingFlexibleWidth,
354    UI32ViewAutoresizingFlexibleRightMargin,
355    UI32ViewAutoresizingFlexibleTopMargin,
356    UI32ViewAutoresizingFlexibleHeight,
357    UI32ViewAutoresizingFlexibleBottomMargin
358};
359typedef uint32_t UI32TableViewCellStyle;
360
361enum
362{
363        UIU8one = 1
364};
365typedef uint8_t UI8Type;
366
367// rdar://19352510
368typedef enum : NSInteger {zero} MyEnum;
369
370typedef enum : NSUInteger {two} MyEnumNSUInteger;
371
372typedef enum : int {three, four} MyEnumint;
373
374typedef enum : unsigned long {five} MyEnumlonglong;
375
376typedef enum : unsigned long long {
377  ll1,
378  ll2= 0xff,
379  ll3,
380  ll4
381} MyEnumunsignedlonglong;
382
383// rdar://19994496
384typedef enum : int8_t {int8_one} MyOneEnum;
385
386typedef enum : int16_t {
387          int16_t_one,
388          int16_t_two } Myint16_tEnum;
389