[cfe-commits] r136209 - in /cfe/trunk: lib/ARCMigrate/TransAPIUses.cpp test/ARCMT/nsdata.m test/ARCMT/nsdata.m.result

Argyrios Kyrtzidis akyrtzi at gmail.com
Tue Jul 26 22:28:22 PDT 2011


Author: akirtzidis
Date: Wed Jul 27 00:28:22 2011
New Revision: 136209

URL: http://llvm.org/viewvc/llvm-project?rev=136209&view=rev
Log:
[arcmt] Revert r135382, there's a different approach in r135764. rdar://9821111.

Removed:
    cfe/trunk/test/ARCMT/nsdata.m
    cfe/trunk/test/ARCMT/nsdata.m.result
Modified:
    cfe/trunk/lib/ARCMigrate/TransAPIUses.cpp

Modified: cfe/trunk/lib/ARCMigrate/TransAPIUses.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/TransAPIUses.cpp?rev=136209&r1=136208&r2=136209&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/TransAPIUses.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/TransAPIUses.cpp Wed Jul 27 00:28:22 2011
@@ -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 @@
   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 @@
     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 @@
       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() &&

Removed: cfe/trunk/test/ARCMT/nsdata.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/nsdata.m?rev=136208&view=auto
==============================================================================
--- cfe/trunk/test/ARCMT/nsdata.m (original)
+++ cfe/trunk/test/ARCMT/nsdata.m (removed)
@@ -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"
-
- at interface NSData : NSObject
-- (const void *)bytes;
- at end
-
-typedef struct _NSRange {
-    NSUInteger location;
-    NSUInteger length;
-} NSRange;
-
- at interface NSData (NSExtendedData)
-- (void)getBytes:(void *)buffer length:(NSUInteger)length;
-- (void)getBytes:(void *)buffer range:(NSRange)range;
- at end
-
- at interface NSData (NSDeprecated)
-- (void)getBytes:(void *)buffer;
- at 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];
-}

Removed: cfe/trunk/test/ARCMT/nsdata.m.result
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/nsdata.m.result?rev=136208&view=auto
==============================================================================
--- cfe/trunk/test/ARCMT/nsdata.m.result (original)
+++ cfe/trunk/test/ARCMT/nsdata.m.result (removed)
@@ -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"
-
- at interface NSData : NSObject
-- (const void *)bytes;
- at end
-
-typedef struct _NSRange {
-    NSUInteger location;
-    NSUInteger length;
-} NSRange;
-
- at interface NSData (NSExtendedData)
-- (void)getBytes:(void *)buffer length:(NSUInteger)length;
-- (void)getBytes:(void *)buffer range:(NSRange)range;
- at end
-
- at interface NSData (NSDeprecated)
-- (void)getBytes:(void *)buffer;
- at 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];
-}





More information about the cfe-commits mailing list