summaryrefslogtreecommitdiff
path: root/docs/AutomaticReferenceCounting.rst
diff options
context:
space:
mode:
authorBen Langmuir <blangmuir@apple.com>2015-02-25 20:09:06 +0000
committerBen Langmuir <blangmuir@apple.com>2015-02-25 20:09:06 +0000
commitb378995a9f641f1bb51f2a6b0f4fde18ad4ab916 (patch)
tree4aecd804f13881ba310be48cded7f1b613f2509a /docs/AutomaticReferenceCounting.rst
parent3cd9f9f0549506f591c0b0e260e244d3c58004ed (diff)
downloadclang-b378995a9f641f1bb51f2a6b0f4fde18ad4ab916.tar.gz
Allow (Object *)kMyGlobalCFObj casts without bridging
Previously we allowed these casts only for constants declared in system headers, which we assume are retain/release-neutral. Now also allow them for constants in user headers, treating them as +0. Practically, this means that we will now allow: id x = (id)kMyGlobalConst; But unlike with system headers we cannot mix them with +1 values: id y = (id)(b ? kMyGlobalConst : [Obj newValAtPlusOne]); // error id z = (id)(b ? kSystemGlobalConst: [Obj newValAtPlusOne]); // OK Thanks to John for suggesting this improvement. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@230534 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'docs/AutomaticReferenceCounting.rst')
-rw-r--r--docs/AutomaticReferenceCounting.rst10
1 files changed, 9 insertions, 1 deletions
diff --git a/docs/AutomaticReferenceCounting.rst b/docs/AutomaticReferenceCounting.rst
index 1457b6082d..2faed23791 100644
--- a/docs/AutomaticReferenceCounting.rst
+++ b/docs/AutomaticReferenceCounting.rst
@@ -594,7 +594,9 @@ retainable pointer type <arc.misc.c-retainable>` and it is:
* a message send, and the declared method either has the
``cf_returns_not_retained`` attribute or it has neither the
``cf_returns_retained`` attribute nor a :ref:`selector family
- <arc.method-families>` that implies a retained result.
+ <arc.method-families>` that implies a retained result, or
+* :when-revised:`[beginning LLVM 3.6]` :revision:`a load from a` ``const``
+ :revision:`non-system global variable.`
An expression is :arc-term:`known retained` if it is an rvalue of :ref:`C
retainable pointer type <arc.misc.c-retainable>` and it is:
@@ -631,6 +633,12 @@ retain-agnostic, the conversion is treated as a ``__bridge`` cast.
to an ObjC-typed local, and then calling ``CFRelease`` when done --- are a
bit too likely to be accidentally accepted, leading to mysterious behavior.
+ For loads from ``const`` global variables of :ref:`C retainable pointer type
+ <arc.misc.c-retainable>`, it is reasonable to assume that global system
+ constants were initialitzed with true constants (e.g. string literals), but
+ user constants might have been initialized with something dynamically
+ allocated, using a global initializer.
+
.. _arc.objects.restrictions.conversion-exception-contextual:
Conversion from retainable object pointer type in certain contexts