ObjectiveC migrator: iDOn't mangle names when

NS_RETURNS_INNER_POINTER annotation is suggested on
a property. // rdar://15044991

llvm-svn: 191332
This commit is contained in:
Fariborz Jahanian 2013-09-24 20:20:52 +00:00
parent 296484eae2
commit 10b7435ceb
3 changed files with 59 additions and 3 deletions

View 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())

View 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

View 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