diff options
author | Ben Langmuir <blangmuir@apple.com> | 2015-02-25 20:09:06 +0000 |
---|---|---|
committer | Ben Langmuir <blangmuir@apple.com> | 2015-02-25 20:09:06 +0000 |
commit | 443aa4b4b0cb7098fdf6ae238ebbbed3f64b4719 (patch) | |
tree | abf52cf459431a6bd388e0ebebd0b3bdcc09f852 /clang/docs/AutomaticReferenceCounting.rst | |
parent | dcc84db2641eaff6efece8502ccc5f3863ef9356 (diff) | |
download | bcm5719-llvm-443aa4b4b0cb7098fdf6ae238ebbbed3f64b4719.tar.gz bcm5719-llvm-443aa4b4b0cb7098fdf6ae238ebbbed3f64b4719.zip |
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.
llvm-svn: 230534
Diffstat (limited to 'clang/docs/AutomaticReferenceCounting.rst')
-rw-r--r-- | clang/docs/AutomaticReferenceCounting.rst | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/clang/docs/AutomaticReferenceCounting.rst b/clang/docs/AutomaticReferenceCounting.rst index 1457b6082d1..2faed237916 100644 --- a/clang/docs/AutomaticReferenceCounting.rst +++ b/clang/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 |