From: Fariborz Jahanian Date: Tue, 24 Sep 2013 20:20:52 +0000 (+0000) Subject: ObjectiveC migrator: iDOn't mangle names when X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f85f5e4769730e06590d969ad3cbff879d8006f6;p=clang ObjectiveC migrator: iDOn't mangle names when NS_RETURNS_INNER_POINTER annotation is suggested on a property. // rdar://15044991 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191332 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/ARCMigrate/ObjCMT.cpp b/lib/ARCMigrate/ObjCMT.cpp index 5cb5d2cb2e..871c8ece05 100644 --- a/lib/ARCMigrate/ObjCMT.cpp +++ b/lib/ARCMigrate/ObjCMT.cpp @@ -53,6 +53,7 @@ class ObjCMigrateASTConsumer : public ASTConsumer { ObjCMethodDecl *OM); bool migrateProperty(ASTContext &Ctx, ObjCContainerDecl *D, ObjCMethodDecl *OM); void migrateNsReturnsInnerPointer(ASTContext &Ctx, ObjCMethodDecl *OM); + void migratePropertyNsReturnsInnerPointer(ASTContext &Ctx, ObjCPropertyDecl *P); void migrateFactoryMethod(ASTContext &Ctx, ObjCContainerDecl *CDecl, ObjCMethodDecl *OM, ObjCInstanceTypeFamily OIT_Family = OIT_None); @@ -350,8 +351,14 @@ void ObjCMigrateASTConsumer::migrateObjCInterfaceDecl(ASTContext &Ctx, ObjCMethodDecl *Method = (*M); if (Method->isDeprecated()) continue; - if (!migrateProperty(Ctx, D, Method)) - migrateNsReturnsInnerPointer(Ctx, Method); + migrateProperty(Ctx, D, Method); + migrateNsReturnsInnerPointer(Ctx, Method); + } + for (ObjCContainerDecl::prop_iterator P = D->prop_begin(), + E = D->prop_end(); P != E; ++P) { + ObjCPropertyDecl *Prop = *P; + if (!P->isDeprecated()) + migratePropertyNsReturnsInnerPointer(Ctx, Prop); } } @@ -831,7 +838,8 @@ bool ObjCMigrateASTConsumer::migrateProperty(ASTContext &Ctx, void ObjCMigrateASTConsumer::migrateNsReturnsInnerPointer(ASTContext &Ctx, ObjCMethodDecl *OM) { - if (OM->hasAttr()) + if (OM->isImplicit() || + OM->hasAttr()) return; QualType RT = OM->getResultType(); @@ -844,6 +852,18 @@ void ObjCMigrateASTConsumer::migrateNsReturnsInnerPointer(ASTContext &Ctx, Editor->commit(commit); } +void ObjCMigrateASTConsumer::migratePropertyNsReturnsInnerPointer(ASTContext &Ctx, + ObjCPropertyDecl *P) { + QualType T = P->getType(); + + if (!TypeIsInnerPointer(T) || + !Ctx.Idents.get("NS_RETURNS_INNER_POINTER").hasMacroDefinition()) + return; + edit::Commit commit(*Editor); + commit.insertBefore(P->getLocEnd(), " NS_RETURNS_INNER_POINTER "); + Editor->commit(commit); +} + void ObjCMigrateASTConsumer::migrateMethods(ASTContext &Ctx, ObjCContainerDecl *CDecl) { if (CDecl->isDeprecated()) diff --git a/test/ARCMT/objcmt-ns-returns-inner-pointer.m b/test/ARCMT/objcmt-ns-returns-inner-pointer.m index 404928398f..d046317b1b 100644 --- a/test/ARCMT/objcmt-ns-returns-inner-pointer.m +++ b/test/ARCMT/objcmt-ns-returns-inner-pointer.m @@ -36,6 +36,8 @@ #define NS_RETURNS_AUTORELEASED __attribute__((ns_returns_autoreleased)) #endif +#define NS_AVAILABLE __attribute__((availability(macosx,introduced=10.0))) + CF_IMPLICIT_BRIDGING_ENABLED typedef unsigned long CFTypeID; @@ -104,3 +106,19 @@ CF_IMPLICIT_BRIDGING_DISABLED - (TTJSObjectRef)JSObject1; - (JSObjectRef*)JSObject2; @end + +// rdar://15044991 +typedef void *SecTrustRef; + +@interface NSURLProtectionSpace +@property (readonly) SecTrustRef serverTrust NS_AVAILABLE; +- (void *) FOO NS_AVAILABLE; +@property (readonly) void * mitTrust NS_AVAILABLE; + +@property (readonly) void * mittiTrust; + +@property (readonly) SecTrustRef XserverTrust; + +- (SecTrustRef) FOO1 NS_AVAILABLE; + +@end diff --git a/test/ARCMT/objcmt-ns-returns-inner-pointer.m.result b/test/ARCMT/objcmt-ns-returns-inner-pointer.m.result index c3f151ab22..8331e1669b 100644 --- a/test/ARCMT/objcmt-ns-returns-inner-pointer.m.result +++ b/test/ARCMT/objcmt-ns-returns-inner-pointer.m.result @@ -36,6 +36,8 @@ #define NS_RETURNS_AUTORELEASED __attribute__((ns_returns_autoreleased)) #endif +#define NS_AVAILABLE __attribute__((availability(macosx,introduced=10.0))) + CF_IMPLICIT_BRIDGING_ENABLED typedef unsigned long CFTypeID; @@ -104,3 +106,19 @@ CF_IMPLICIT_BRIDGING_DISABLED - (TTJSObjectRef)JSObject1; - (JSObjectRef*)JSObject2 NS_RETURNS_INNER_POINTER; @end + +// rdar://15044991 +typedef void *SecTrustRef; + +@interface NSURLProtectionSpace +@property (readonly) SecTrustRef NS_RETURNS_INNER_POINTER serverTrust NS_AVAILABLE; +- (void *) FOO NS_AVAILABLE NS_RETURNS_INNER_POINTER; +@property (readonly) void * NS_RETURNS_INNER_POINTER mitTrust NS_AVAILABLE; + +@property (readonly) void * NS_RETURNS_INNER_POINTER mittiTrust; + +@property (readonly) SecTrustRef NS_RETURNS_INNER_POINTER XserverTrust; + +- (SecTrustRef) FOO1 NS_AVAILABLE NS_RETURNS_INNER_POINTER; + +@end