diff --git a/lib/ARCMigrate/TransAPIUses.cpp b/lib/ARCMigrate/TransAPIUses.cpp index 781ad7742d..aaa82d8dfb 100644 --- a/lib/ARCMigrate/TransAPIUses.cpp +++ b/lib/ARCMigrate/TransAPIUses.cpp @@ -13,8 +13,6 @@ // // - NSInvocation's [get/set]ReturnValue and [get/set]Argument are only safe // with __unsafe_unretained objects. -// - When a NSData's 'bytes' family of methods are used on a local var, -// add __attribute__((objc_precise_lifetime)) to make it safer. // - Calling -zone gets replaced with 'nil'. // //===----------------------------------------------------------------------===// @@ -35,11 +33,7 @@ class APIChecker : public RecursiveASTVisitor { Selector getReturnValueSel, setReturnValueSel; Selector getArgumentSel, setArgumentSel; - Selector bytesSel, getBytesSel, getBytesLengthSel, getBytesRangeSel; - Selector zoneSel; - - llvm::DenseSet ChangedNSDataVars; public: APIChecker(MigrationPass &pass) : Pass(pass) { SelectorTable &sels = Pass.Ctx.Selectors; @@ -54,14 +48,6 @@ public: selIds[0] = &ids.get("setArgument"); setArgumentSel = sels.getSelector(2, selIds); - bytesSel = sels.getNullarySelector(&ids.get("bytes")); - getBytesSel = sels.getUnarySelector(&ids.get("getBytes")); - selIds[0] = &ids.get("getBytes"); - selIds[1] = &ids.get("length"); - getBytesLengthSel = sels.getSelector(2, selIds); - selIds[1] = &ids.get("range"); - getBytesRangeSel = sels.getSelector(2, selIds); - zoneSel = sels.getNullarySelector(&ids.get("zone")); } @@ -98,27 +84,6 @@ public: return true; } - // NSData. - if (E->isInstanceMessage() && - E->getReceiverInterface() && - E->getReceiverInterface()->getName() == "NSData" && - E->getInstanceReceiver() && - (E->getSelector() == bytesSel || - E->getSelector() == getBytesSel || - E->getSelector() == getBytesLengthSel || - E->getSelector() == getBytesRangeSel)) { - Expr *rec = E->getInstanceReceiver(); - rec = rec->IgnoreParenCasts(); - if (DeclRefExpr *DRE = dyn_cast(rec)) - if (VarDecl *VD = dyn_cast(DRE->getDecl())) - if (VD->hasLocalStorage() && !ChangedNSDataVars.count(VD)) { - Transaction Trans(Pass.TA); - Pass.TA.insertAfterToken(VD->getLocation(), - " __attribute__((objc_precise_lifetime))"); - ChangedNSDataVars.insert(VD); - } - } - // -zone. if (E->isInstanceMessage() && E->getInstanceReceiver() && diff --git a/test/ARCMT/nsdata.m b/test/ARCMT/nsdata.m deleted file mode 100644 index c4a555d5bd..0000000000 --- a/test/ARCMT/nsdata.m +++ /dev/null @@ -1,32 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -@interface NSData : NSObject -- (const void *)bytes; -@end - -typedef struct _NSRange { - NSUInteger location; - NSUInteger length; -} NSRange; - -@interface NSData (NSExtendedData) -- (void)getBytes:(void *)buffer length:(NSUInteger)length; -- (void)getBytes:(void *)buffer range:(NSRange)range; -@end - -@interface NSData (NSDeprecated) -- (void)getBytes:(void *)buffer; -@end - -void test(NSData* parmdata) { - NSData *data, *data2 = parmdata; - void *p = [data bytes]; - p = [data bytes]; - - [data2 getBytes:&p length:sizeof(p)]; - p = [parmdata bytes]; -} diff --git a/test/ARCMT/nsdata.m.result b/test/ARCMT/nsdata.m.result deleted file mode 100644 index 0ca2a713b5..0000000000 --- a/test/ARCMT/nsdata.m.result +++ /dev/null @@ -1,32 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -@interface NSData : NSObject -- (const void *)bytes; -@end - -typedef struct _NSRange { - NSUInteger location; - NSUInteger length; -} NSRange; - -@interface NSData (NSExtendedData) -- (void)getBytes:(void *)buffer length:(NSUInteger)length; -- (void)getBytes:(void *)buffer range:(NSRange)range; -@end - -@interface NSData (NSDeprecated) -- (void)getBytes:(void *)buffer; -@end - -void test(NSData* parmdata __attribute__((objc_precise_lifetime))) { - NSData *data __attribute__((objc_precise_lifetime)), *data2 __attribute__((objc_precise_lifetime)) = parmdata; - void *p = [data bytes]; - p = [data bytes]; - - [data2 getBytes:&p length:sizeof(p)]; - p = [parmdata bytes]; -}