Objective-C SDK modernization. import Foundation even
when a previous definition of NS_OPTION is available ; e.g. from a pch. enhancement to rdar://18498550 llvm-svn: 219448
This commit is contained in:
parent
6030e04591
commit
d2241bf561
|
@ -918,8 +918,7 @@ bool ObjCMigrateASTConsumer::migrateNSEnumDecl(ASTContext &Ctx,
|
|||
if (const EnumType *EnumTy = qt->getAs<EnumType>()) {
|
||||
if (EnumTy->getDecl() == EnumDcl) {
|
||||
bool NSOptions = UseNSOptionsMacro(PP, Ctx, EnumDcl);
|
||||
if (!Ctx.Idents.get("NS_ENUM").hasMacroDefinition() &&
|
||||
!InsertFoundation(Ctx, TypedefDcl->getLocStart()))
|
||||
if (!InsertFoundation(Ctx, TypedefDcl->getLocStart()))
|
||||
return false;
|
||||
edit::Commit commit(*Editor);
|
||||
rewriteToNSMacroDecl(EnumDcl, TypedefDcl, *NSAPIObj, commit, !NSOptions);
|
||||
|
@ -932,9 +931,7 @@ bool ObjCMigrateASTConsumer::migrateNSEnumDecl(ASTContext &Ctx,
|
|||
|
||||
// We may still use NS_OPTIONS based on what we find in the enumertor list.
|
||||
bool NSOptions = UseNSOptionsMacro(PP, Ctx, EnumDcl);
|
||||
// For sanity check, see if macro NS_ENUM can be seen.
|
||||
if (!Ctx.Idents.get("NS_ENUM").hasMacroDefinition()
|
||||
&& !InsertFoundation(Ctx, TypedefDcl->getLocStart()))
|
||||
if (!InsertFoundation(Ctx, TypedefDcl->getLocStart()))
|
||||
return false;
|
||||
edit::Commit commit(*Editor);
|
||||
bool Res = rewriteToNSEnumDecl(EnumDcl, TypedefDcl, *NSAPIObj,
|
||||
|
@ -1727,9 +1724,9 @@ bool ObjCMigrateASTConsumer::InsertFoundation(ASTContext &Ctx,
|
|||
return false;
|
||||
edit::Commit commit(*Editor);
|
||||
if (Ctx.getLangOpts().Modules)
|
||||
commit.insert(Loc, "@import Foundation;\n");
|
||||
commit.insert(Loc, "#ifndef NS_ENUM\n@import Foundation;\n#endif\n");
|
||||
else
|
||||
commit.insert(Loc, "#import <Foundation/Foundation.h>\n");
|
||||
commit.insert(Loc, "#ifndef NS_ENUM\n#import <Foundation/Foundation.h>\n#endif\n");
|
||||
Editor->commit(commit);
|
||||
FoundationIncluded = true;
|
||||
return true;
|
||||
|
|
|
@ -19,6 +19,9 @@ typedef unsigned long long uint64_t;
|
|||
#define NS_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type
|
||||
#define DEPRECATED __attribute__((deprecated))
|
||||
|
||||
#ifndef NS_ENUM
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
typedef NS_ENUM(NSInteger, wibble) {
|
||||
blah,
|
||||
blarg
|
||||
|
|
|
@ -5,7 +5,9 @@
|
|||
// rdar://18498550
|
||||
|
||||
typedef long NSInteger;
|
||||
#ifndef NS_ENUM
|
||||
@import Foundation;
|
||||
#endif
|
||||
typedef NS_OPTIONS(NSUInteger, UITableStyle) {
|
||||
UIViewNone = 0x0,
|
||||
UIViewMargin = 0x1,
|
||||
|
|
Loading…
Reference in New Issue