forked from OSchip/llvm-project
ObjectiveC migrator. Place use of NS_NONATOMIC_IOSONLY
on inferred property attribute under -objcmt-ns-nonatomic-iosonly option. // rdar://15442742 llvm-svn: 194532
This commit is contained in:
parent
008c45f1a1
commit
2e793d6124
|
@ -183,6 +183,8 @@ def objcmt_atomic_property : Flag<["-"], "objcmt-atomic-property">,
|
|||
HelpText<"Make migration to 'atomic' properties">;
|
||||
def objcmt_returns_innerpointer_property : Flag<["-"], "objcmt-returns-innerpointer-property">, Flags<[CC1Option]>,
|
||||
HelpText<"Enable migration to annotate property with NS_RETURNS_INNER_POINTER">;
|
||||
def objcmt_ns_nonatomic_iosonly: Flag<["-"], "objcmt-ns-nonatomic-iosonly">, Flags<[CC1Option]>,
|
||||
HelpText<"Enable migration to use NS_NONATOMIC_IOSONLY macro for setting property's 'atomic' attribute">;
|
||||
|
||||
// Make sure all other -ccc- options are rejected.
|
||||
def ccc_ : Joined<["-"], "ccc-">, Group<internal_Group>, Flags<[Unsupported]>;
|
||||
|
|
|
@ -177,13 +177,13 @@ public:
|
|||
ObjCMT_AtomicProperty = 0x100,
|
||||
/// \brief annotate property with NS_RETURNS_INNER_POINTER
|
||||
ObjCMT_ReturnsInnerPointerProperty = 0x200,
|
||||
/// \brief use NS_NONATOMIC_IOSONLY for property 'atomic' attribute
|
||||
ObjCMT_NsAtomicIOSOnlyProperty = 0x400,
|
||||
ObjCMT_MigrateDecls = (ObjCMT_ReadonlyProperty | ObjCMT_ReadwriteProperty |
|
||||
ObjCMT_Annotation | ObjCMT_Instancetype |
|
||||
ObjCMT_NsMacros | ObjCMT_ProtocolConformance),
|
||||
ObjCMT_MigrateAll = (ObjCMT_Literals | ObjCMT_Subscripting |
|
||||
ObjCMT_ReadonlyProperty | ObjCMT_ReadwriteProperty |
|
||||
ObjCMT_Annotation | ObjCMT_Instancetype |
|
||||
ObjCMT_NsMacros | ObjCMT_ProtocolConformance)
|
||||
ObjCMT_NsMacros | ObjCMT_ProtocolConformance |
|
||||
ObjCMT_NsAtomicIOSOnlyProperty),
|
||||
ObjCMT_MigrateAll = (ObjCMT_Literals | ObjCMT_Subscripting | ObjCMT_MigrateDecls)
|
||||
};
|
||||
unsigned ObjCMTAction;
|
||||
|
||||
|
|
|
@ -278,11 +278,12 @@ static void rewriteToObjCProperty(const ObjCMethodDecl *Getter,
|
|||
const ObjCMethodDecl *Setter,
|
||||
const NSAPI &NS, edit::Commit &commit,
|
||||
unsigned LengthOfPrefix,
|
||||
bool Atomic, bool AvailabilityArgsMatch) {
|
||||
bool Atomic, bool UseNsIosOnlyMacro,
|
||||
bool AvailabilityArgsMatch) {
|
||||
ASTContext &Context = NS.getASTContext();
|
||||
bool LParenAdded = false;
|
||||
std::string PropertyString = "@property ";
|
||||
if (Context.Idents.get("NS_NONATOMIC_IOSONLY").hasMacroDefinition()) {
|
||||
if (UseNsIosOnlyMacro && Context.Idents.get("NS_NONATOMIC_IOSONLY").hasMacroDefinition()) {
|
||||
PropertyString += "(NS_NONATOMIC_IOSONLY";
|
||||
LParenAdded = true;
|
||||
} else if (!Atomic) {
|
||||
|
@ -1078,6 +1079,8 @@ bool ObjCMigrateASTConsumer::migrateProperty(ASTContext &Ctx,
|
|||
LengthOfPrefix,
|
||||
(ASTMigrateActions &
|
||||
FrontendOptions::ObjCMT_AtomicProperty) != 0,
|
||||
(ASTMigrateActions &
|
||||
FrontendOptions::ObjCMT_NsAtomicIOSOnlyProperty) != 0,
|
||||
AvailabilityArgsMatch);
|
||||
Editor->commit(commit);
|
||||
return true;
|
||||
|
@ -1090,6 +1093,8 @@ bool ObjCMigrateASTConsumer::migrateProperty(ASTContext &Ctx,
|
|||
LengthOfPrefix,
|
||||
(ASTMigrateActions &
|
||||
FrontendOptions::ObjCMT_AtomicProperty) != 0,
|
||||
(ASTMigrateActions &
|
||||
FrontendOptions::ObjCMT_NsAtomicIOSOnlyProperty) != 0,
|
||||
/*AvailabilityArgsMatch*/false);
|
||||
Editor->commit(commit);
|
||||
return true;
|
||||
|
|
|
@ -815,6 +815,8 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
|
|||
Opts.ObjCMTAction |= FrontendOptions::ObjCMT_ProtocolConformance;
|
||||
if (Args.hasArg(OPT_objcmt_atomic_property))
|
||||
Opts.ObjCMTAction |= FrontendOptions::ObjCMT_AtomicProperty;
|
||||
if (Args.hasArg(OPT_objcmt_ns_nonatomic_iosonly))
|
||||
Opts.ObjCMTAction |= FrontendOptions::ObjCMT_NsAtomicIOSOnlyProperty;
|
||||
if (Args.hasArg(OPT_objcmt_migrate_all))
|
||||
Opts.ObjCMTAction |= FrontendOptions::ObjCMT_MigrateDecls;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// RUN: rm -rf %t
|
||||
// RUN: %clang_cc1 -fblocks -objcmt-migrate-readwrite-property -objcmt-migrate-readonly-property -objcmt-atomic-property -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11
|
||||
// RUN: %clang_cc1 -fblocks -objcmt-migrate-readwrite-property -objcmt-ns-nonatomic-iosonly -objcmt-migrate-readonly-property -objcmt-atomic-property -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11
|
||||
// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
|
||||
// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// RUN: rm -rf %t
|
||||
// RUN: %clang_cc1 -fblocks -objcmt-migrate-readwrite-property -objcmt-migrate-readonly-property -objcmt-atomic-property -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11
|
||||
// RUN: %clang_cc1 -fblocks -objcmt-migrate-readwrite-property -objcmt-ns-nonatomic-iosonly -objcmt-migrate-readonly-property -objcmt-atomic-property -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11
|
||||
// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
|
||||
// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result
|
||||
|
||||
|
|
Loading…
Reference in New Issue