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