]> granicus.if.org Git - clang/commitdiff
ObjectiveC migrator: iDOn't mangle names when
authorFariborz Jahanian <fjahanian@apple.com>
Tue, 24 Sep 2013 20:20:52 +0000 (20:20 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Tue, 24 Sep 2013 20:20:52 +0000 (20:20 +0000)
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

lib/ARCMigrate/ObjCMT.cpp
test/ARCMT/objcmt-ns-returns-inner-pointer.m
test/ARCMT/objcmt-ns-returns-inner-pointer.m.result

index 5cb5d2cb2effb5963a4d0fb489c1ae78f20724f9..871c8ece054ebca569eb6f03cce8d1eebd4a3080 100644 (file)
@@ -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<ObjCReturnsInnerPointerAttr>())
+  if (OM->isImplicit() ||
+      OM->hasAttr<ObjCReturnsInnerPointerAttr>())
     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())
index 404928398fe59a12ce0711a8312cf37df08fc23a..d046317b1b450237dae90de541d247a49eafb75d 100644 (file)
@@ -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
index c3f151ab2231cd93f46a894df392de3d4615f5fe..8331e1669b1247f604b28fdf349bf4a1db215b1a 100644 (file)
@@ -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