diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-07-14 22:46:12 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-07-14 22:46:12 +0000 |
commit | 2cd5366ff52b4592776ee4db27012d16fb995c62 (patch) | |
tree | b5dc8cba08508ab837cd165235687c7a3257bcb9 | |
parent | 00fe761849278180b0d73f276e468cf4c54ff2ad (diff) |
[arcmt] Allow -retain of an __unsafe_unretained receiver if the result gets used.
Keep the error if the result is unused. rdar://9552694.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135209 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/ARCMigrate/TransRetainReleaseDealloc.cpp | 3 | ||||
-rw-r--r-- | test/ARCMT/checking.m | 1 |
2 files changed, 3 insertions, 1 deletions
diff --git a/lib/ARCMigrate/TransRetainReleaseDealloc.cpp b/lib/ARCMigrate/TransRetainReleaseDealloc.cpp index d64250faf0..4eeb47437e 100644 --- a/lib/ARCMigrate/TransRetainReleaseDealloc.cpp +++ b/lib/ARCMigrate/TransRetainReleaseDealloc.cpp @@ -70,7 +70,8 @@ public: if (E->getReceiverKind() == ObjCMessageExpr::Instance) if (Expr *rec = E->getInstanceReceiver()) { rec = rec->IgnoreParenImpCasts(); - if (rec->getType().getObjCLifetime() == Qualifiers::OCL_ExplicitNone){ + if (rec->getType().getObjCLifetime() == Qualifiers::OCL_ExplicitNone && + (E->getMethodFamily() != OMF_retain || isRemovable(E))) { std::string err = "it is not safe to remove '"; err += E->getSelector().getAsString() + "' message on " "an __unsafe_unretained type"; diff --git a/test/ARCMT/checking.m b/test/ARCMT/checking.m index 4dea3b71df..7ab54ceb05 100644 --- a/test/ARCMT/checking.m +++ b/test/ARCMT/checking.m @@ -39,6 +39,7 @@ struct UnsafeS { void test1(A *a, BOOL b, struct UnsafeS *unsafeS) { [unsafeS->unsafeObj retain]; // expected-error {{it is not safe to remove 'retain' message on an __unsafe_unretained type}} \ // expected-error {{ARC forbids explicit message send}} + id foo = [unsafeS->unsafeObj retain]; // no warning. [a dealloc]; [a retain]; [a retainCount]; // expected-error {{ARC forbids explicit message send of 'retainCount'}} |