diff options
author | John McCall <rjmccall@apple.com> | 2016-01-27 18:32:30 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2016-01-27 18:32:30 +0000 |
commit | 7164cefe40037ea1b60aadfc93f4e0f5d9a1c628 (patch) | |
tree | a41a201ac908bb961cece7099b94d9ef13f8e252 /include/clang/Basic/ObjCRuntime.h | |
parent | 9909f323ce49b0a630c8c7d6805f41c2c84d1fb6 (diff) |
Emit calls to objc_unsafeClaimAutoreleasedReturnValue when
reclaiming a call result in order to ignore it or assign it
to an __unsafe_unretained variable. This avoids adding
an unwanted retain/release pair when the return value is
not actually returned autoreleased (e.g. when it is returned
from a nonatomic getter or a typical collection accessor).
This runtime function is only available on the latest Apple
OS releases; the backwards-compatibility story is that you
don't get the optimization unless your deployment target is
recent enough. Sorry.
rdar://20530049
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@258962 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/ObjCRuntime.h')
-rw-r--r-- | include/clang/Basic/ObjCRuntime.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/include/clang/Basic/ObjCRuntime.h b/include/clang/Basic/ObjCRuntime.h index cf51b146b1..6975b6c9bb 100644 --- a/include/clang/Basic/ObjCRuntime.h +++ b/include/clang/Basic/ObjCRuntime.h @@ -308,6 +308,23 @@ public: } } + /// Is objc_unsafeClaimAutoreleasedReturnValue available? + bool hasARCUnsafeClaimAutoreleasedReturnValue() const { + switch (getKind()) { + case MacOSX: + return getVersion() >= VersionTuple(10, 11); + case iOS: + return getVersion() >= VersionTuple(9); + case WatchOS: + return getVersion() >= VersionTuple(2); + case GNUstep: + return false; + + default: + return false; + } + } + /// \brief Try to parse an Objective-C runtime specification from the given /// string. /// |