[arcmt] Revert r135382, there's a different approach in r135764. rdar://9821111.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136209 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Argyrios Kyrtzidis 2011-07-27 05:28:22 +00:00
Родитель 18fd0c6915
Коммит 6fa8f86b81
3 изменённых файлов: 0 добавлений и 99 удалений

Просмотреть файл

@ -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<APIChecker> {
Selector getReturnValueSel, setReturnValueSel;
Selector getArgumentSel, setArgumentSel;
Selector bytesSel, getBytesSel, getBytesLengthSel, getBytesRangeSel;
Selector zoneSel;
llvm::DenseSet<VarDecl *> 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<DeclRefExpr>(rec))
if (VarDecl *VD = dyn_cast<VarDecl>(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() &&

Просмотреть файл

@ -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];
}

Просмотреть файл

@ -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];
}