static bool rewriteToNSEnumDecl(const EnumDecl *EnumDcl,
const TypedefDecl *TypedefDcl,
- const NSAPI &NS, edit::Commit &commit) {
- std::string ClassString = "typedef NS_ENUM(NSInteger, ";
+ const NSAPI &NS, edit::Commit &commit,
+ bool IsNSIntegerType) {
+ std::string ClassString =
+ IsNSIntegerType ? "typedef NS_ENUM(NSInteger, " : "typedef NS_OPTIONS(NSUInteger, ";
ClassString += TypedefDcl->getIdentifier()->getName();
ClassString += ')';
SourceRange R(EnumDcl->getLocStart(), EnumDcl->getLocStart());
return;
QualType qt = TypedefDcl->getTypeSourceInfo()->getType();
- if (!NSAPIObj->isObjCNSIntegerType(qt))
+ bool IsNSIntegerType = NSAPIObj->isObjCNSIntegerType(qt);
+ bool IsNSUIntegerType = !IsNSIntegerType && NSAPIObj->isObjCNSUIntegerType(qt);
+ if (!IsNSIntegerType && !IsNSUIntegerType)
return;
// NS_ENUM must be available.
- if (!Ctx.Idents.get("NS_ENUM").hasMacroDefinition())
+ if (IsNSIntegerType && !Ctx.Idents.get("NS_ENUM").hasMacroDefinition())
+ return;
+ // NS_OPTIONS must be available.
+ if (IsNSUIntegerType && !Ctx.Idents.get("NS_OPTIONS").hasMacroDefinition())
return;
edit::Commit commit(*Editor);
- rewriteToNSEnumDecl(EnumDcl, TypedefDcl, *NSAPIObj, commit);
+ rewriteToNSEnumDecl(EnumDcl, TypedefDcl, *NSAPIObj, commit, IsNSIntegerType);
Editor->commit(commit);
}
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc -fobjc-default-synthesize-properties %s.result
typedef long NSInteger;
+typedef unsigned long NSUInteger;
+
#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
+#define NS_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type
enum {
blah,
blarg
};
typedef NSInteger wibble;
+
+enum {
+ UIViewAutoresizingNone = 0,
+ UIViewAutoresizingFlexibleLeftMargin = 1 << 0,
+ UIViewAutoresizingFlexibleWidth = 1 << 1,
+ UIViewAutoresizingFlexibleRightMargin = 1 << 2,
+ UIViewAutoresizingFlexibleTopMargin = 1 << 3,
+ UIViewAutoresizingFlexibleHeight = 1 << 4,
+ UIViewAutoresizingFlexibleBottomMargin = 1 << 5
+};
+
+typedef NSUInteger UITableViewCellStyle;
+
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc -fobjc-default-synthesize-properties %s.result
typedef long NSInteger;
+typedef unsigned long NSUInteger;
+
#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
+#define NS_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type
typedef NS_ENUM(NSInteger, wibble) {
blah,
blarg
};
+
+typedef NS_OPTIONS(NSUInteger, UITableViewCellStyle) {
+ UIViewAutoresizingNone = 0,
+ UIViewAutoresizingFlexibleLeftMargin = 1 << 0,
+ UIViewAutoresizingFlexibleWidth = 1 << 1,
+ UIViewAutoresizingFlexibleRightMargin = 1 << 2,
+ UIViewAutoresizingFlexibleTopMargin = 1 << 3,
+ UIViewAutoresizingFlexibleHeight = 1 << 4,
+ UIViewAutoresizingFlexibleBottomMargin = 1 << 5
+};
+
+
+