From: Argyrios Kyrtzidis Date: Thu, 17 May 2012 18:16:05 +0000 (+0000) Subject: [arcmt] Remove the "it is not safe to remove an unused 'autorelease' message" ARC X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3d6439517c37d54d48dcf99e389020efa52dc899;p=platform%2Fupstream%2Fllvm.git [arcmt] Remove the "it is not safe to remove an unused 'autorelease' message" ARC migration error. This is more trouble that it is worth; autoreleasing a value without holding on it is a valid use-case, we should not "punish" correct code for the minority of broken/fragile programs that depend on the behavior of -autorelease. rdar://9914061 llvm-svn: 156999 --- diff --git a/clang/lib/ARCMigrate/TransRetainReleaseDealloc.cpp b/clang/lib/ARCMigrate/TransRetainReleaseDealloc.cpp index 11a6553..976c097 100644 --- a/clang/lib/ARCMigrate/TransRetainReleaseDealloc.cpp +++ b/clang/lib/ARCMigrate/TransRetainReleaseDealloc.cpp @@ -63,17 +63,6 @@ public: break; return true; case OMF_autorelease: - if (isRemovable(E)) { - // An unused autorelease is badness. If we remove it the receiver - // will likely die immediately while previously it was kept alive - // by the autorelease pool. This is bad practice in general, leave it - // and emit an error to force the user to restructure his code. - Pass.TA.reportError("it is not safe to remove an unused 'autorelease' " - "message; its receiver may be destroyed immediately", - E->getLocStart(), E->getSourceRange()); - return true; - } - // Pass through. case OMF_retain: case OMF_release: if (E->getReceiverKind() == ObjCMessageExpr::Instance) diff --git a/clang/test/ARCMT/checking.m b/clang/test/ARCMT/checking.m index cf71611..73eba9f 100644 --- a/clang/test/ARCMT/checking.m +++ b/clang/test/ARCMT/checking.m @@ -89,8 +89,7 @@ void test1(A *a, BOOL b, struct UnsafeS *unsafeS) { [a retain]; [a retainCount]; // expected-error {{ARC forbids explicit message send of 'retainCount'}} [a release]; - [a autorelease]; // expected-error {{it is not safe to remove an unused 'autorelease' message; its receiver may be destroyed immediately}} \ - // expected-error {{ARC forbids explicit message send}} + [a autorelease]; CFStringRef cfstr; NSString *str = (NSString *)cfstr; // expected-error {{cast of C pointer type 'CFStringRef' (aka 'const struct __CFString *') to Objective-C pointer type 'NSString *' requires a bridged cast}} \