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 | 08903e4c167d1e8740c4df8f67f904e917fea8c2 (patch) | |
| tree | 021d0bf28a1a317b9b7cfdacf6fa456661fe9d01 /clang | |
| parent | 5143181ff961706cd845c7e85f30f1fde2e5a03c (diff) | |
| download | bcm5719-llvm-08903e4c167d1e8740c4df8f67f904e917fea8c2.tar.gz bcm5719-llvm-08903e4c167d1e8740c4df8f67f904e917fea8c2.zip | |
[arcmt] Allow -retain of an __unsafe_unretained receiver if the result gets used.
Keep the error if the result is unused. rdar://9552694.
llvm-svn: 135209
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/ARCMigrate/TransRetainReleaseDealloc.cpp | 3 | ||||
| -rw-r--r-- | clang/test/ARCMT/checking.m | 1 |
2 files changed, 3 insertions, 1 deletions
diff --git a/clang/lib/ARCMigrate/TransRetainReleaseDealloc.cpp b/clang/lib/ARCMigrate/TransRetainReleaseDealloc.cpp index d64250faf02..4eeb47437e3 100644 --- a/clang/lib/ARCMigrate/TransRetainReleaseDealloc.cpp +++ b/clang/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/clang/test/ARCMT/checking.m b/clang/test/ARCMT/checking.m index 4dea3b71dff..7ab54ceb05d 100644 --- a/clang/test/ARCMT/checking.m +++ b/clang/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'}} |

