<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Yes, you are correct: clang implicitly marks indirect parameters with __autoreleasing.</div><div class=""><br class=""></div><div class="">The whole purpose of Wblock-capture-autoreleasing (which was committed in r285031) is to inform the users that clang has implicitly marked an out-parameter as __autoreleasing. clang doesn’t warn if the user explicitly marks the parameter __autoreleasing.</div><br class=""><div><blockquote type="cite" class=""><div class="">On Feb 13, 2017, at 8:09 AM, Nico Weber <<a href="mailto:thakis@chromium.org" class="">thakis@chromium.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">If I'm understanding you correctly, you're saying that clang implicitly marks the indirect NSError** parameter with __autoreleasing, so there's no bug here. Is that correct? If so, should Wblock-capture-autoreleasing just not fire on parameters that are already implicitly marked as __autoreleasing?</div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Mon, Feb 13, 2017 at 1:54 AM, Akira Hatanaka <span dir="ltr" class=""><<a href="mailto:ahatanaka@apple.com" target="_blank" class="">ahatanaka@apple.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class="">Hi Nico,</div><div class=""><br class=""></div><div class="">The documentation might confuse people now that the warning is on by default, but it’s correct as clang still qualifies indirect parameters with __autoreleasing. We had to add this warning and turn it on by default because a lot of people capture indirect parameters in their code not realizing the object assigned might get released by an autorelease pool.</div><div class=""><br class=""></div><div class="">Perhaps we can change the warning message or the documentation to make it clear that the parameter has been implicitly marked __autoreleasing regardless.</div><div class=""><div class="h5"><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class="">On Feb 11, 2017, at 11:54 AM, Nico Weber <<a href="mailto:thakis@chromium.org" target="_blank" class="">thakis@chromium.org</a>> wrote:</div><br class="m_1176563679087254367Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hi Akira,<div class=""><br class=""></div><div class="">this fires in internal chrome/ios code like so:</div><div class=""><br class=""></div><div class=""><div class="">somefile.m: error: block captures an autoreleasing out-parameter, which may result in use-after-free bugs [-Werror,-Wblock-capture-<wbr class="">autoreleasing]</div><div class=""> if (error) {</div><div class=""> ^</div><div class="">somefile.m: note: declare the parameter __autoreleasing explicitly to suppress this warning</div><div class="">- (NSDictionary *)fooWithError:(NSError **)error {</div><div class=""> ^</div><div class=""> __autoreleasing</div><div class="">somefile.m: note: declare the parameter __strong or capture a __block __strong variable to keep values alive across autorelease pools</div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">A colleague points out that <a href="http://clang.llvm.org/docs/AutomaticReferenceCounting.html#indirect-parameters" target="_blank" class="">http://clang.llvm.org/<wbr class="">docs/<wbr class="">AutomaticReferenceCounting.<wbr class="">html#indirect-parameters</a> suggests NSError ** should "be implicitly qualified with __autoreleasing." Is that a bug in the implementation of the warning, is AutomaticReferenceCounting.<wbr class="">html incorrect, or are we just misunderstanding that document?</div><div class=""><br class="">Thanks,</div><div class="">Nico</div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Thu, Jan 26, 2017 at 1:51 PM, Akira Hatanaka via cfe-commits <span dir="ltr" class=""><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank" class="">cfe-commits@lists.llvm.org</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: ahatanak<br class="">
Date: Thu Jan 26 12:51:10 2017<br class="">
New Revision: 293199<br class="">
<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=293199&view=rev" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-pr<wbr class="">oject?rev=293199&view=rev</a><br class="">
Log:<br class="">
Turn on -Wblock-capture-autoreleasing by default.<br class="">
<br class="">
Turning on the warning by default helps the users as it's a common<br class="">
mistake to capture out-parameters in a block without ensuring the object<br class="">
assigned doesn't get released.<br class="">
<br class="">
<a class="">rdar://problem/30200058</a><br class="">
<br class="">
Modified:<br class="">
cfe/trunk/include/clang/Basic/<wbr class="">DiagnosticSemaKinds.td<br class="">
cfe/trunk/test/SemaObjC/arc.m<br class="">
<br class="">
Modified: cfe/trunk/include/clang/Basic/<wbr class="">DiagnosticSemaKinds.td<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=293199&r1=293198&r2=293199&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-pr<wbr class="">oject/cfe/trunk/include/clang/<wbr class="">Basic/DiagnosticSemaKinds.td?<wbr class="">rev=293199&r1=293198&r2=<wbr class="">293199&view=diff</a><br class="">
==============================<wbr class="">==============================<wbr class="">==================<br class="">
--- cfe/trunk/include/clang/Basic/<wbr class="">DiagnosticSemaKinds.td (original)<br class="">
+++ cfe/trunk/include/clang/Basic/<wbr class="">DiagnosticSemaKinds.td Thu Jan 26 12:51:10 2017<br class="">
@@ -5185,7 +5185,7 @@ def err_arc_inconsistent_property_<wbr class="">owners<br class="">
def warn_block_capture_autoreleasi<wbr class="">ng : Warning<<br class="">
"block captures an autoreleasing out-parameter, which may result in "<br class="">
"use-after-free bugs">,<br class="">
- InGroup<BlockCaptureAutoReleas<wbr class="">ing>, DefaultIgnore;<br class="">
+ InGroup<BlockCaptureAutoReleas<wbr class="">ing>;<br class="">
def note_declare_parameter_autorel<wbr class="">easing : Note<<br class="">
"declare the parameter __autoreleasing explicitly to suppress this warning">;<br class="">
def note_declare_parameter_strong : Note<<br class="">
<br class="">
Modified: cfe/trunk/test/SemaObjC/arc.m<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/arc.m?rev=293199&r1=293198&r2=293199&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-pr<wbr class="">oject/cfe/trunk/test/SemaObjC/<wbr class="">arc.m?rev=293199&r1=293198&r2=<wbr class="">293199&view=diff</a><br class="">
==============================<wbr class="">==============================<wbr class="">==================<br class="">
--- cfe/trunk/test/SemaObjC/arc.m (original)<br class="">
+++ cfe/trunk/test/SemaObjC/arc.m Thu Jan 26 12:51:10 2017<br class="">
@@ -1,4 +1,4 @@<br class="">
-// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -fblocks -verify -Wno-objc-root-class -Wblock-capture-autoreleasing %s<br class="">
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -fblocks -verify -Wno-objc-root-class %s<br class="">
<br class="">
typedef unsigned long NSUInteger;<br class="">
typedef const void * CFTypeRef;<br class="">
<br class="">
<br class="">
______________________________<wbr class="">_________________<br class="">
cfe-commits mailing list<br class="">
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank" class="">cfe-commits@lists.llvm.org</a><br class="">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/<wbr class="">mailman/listinfo/cfe-commits</a><br class="">
</blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></body></html>