<div dir="ltr">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><div class="gmail_quote">On Mon, Feb 13, 2017 at 1:54 AM, Akira Hatanaka <span dir="ltr"><<a href="mailto:ahatanaka@apple.com" target="_blank">ahatanaka@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>Hi Nico,</div><div><br></div><div>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><br></div><div>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><div class="h5"><div><br></div><div><blockquote type="cite"><div>On Feb 11, 2017, at 11:54 AM, Nico Weber <<a href="mailto:thakis@chromium.org" target="_blank">thakis@chromium.org</a>> wrote:</div><br class="m_1176563679087254367Apple-interchange-newline"><div><div dir="ltr">Hi Akira,<div><br></div><div>this fires in internal chrome/ios code like so:</div><div><br></div><div><div>somefile.m: error: block captures an autoreleasing out-parameter, which may result in use-after-free bugs [-Werror,-Wblock-capture-<wbr>autoreleasing]</div><div> if (error) {</div><div> ^</div><div>somefile.m: note: declare the parameter __autoreleasing explicitly to suppress this warning</div><div>- (NSDictionary *)fooWithError:(NSError **)error {</div><div> ^</div><div> __autoreleasing</div><div>somefile.m: note: declare the parameter __strong or capture a __block __strong variable to keep values alive across autorelease pools</div></div><div><br></div><div><br></div><div>A colleague points out that <a href="http://clang.llvm.org/docs/AutomaticReferenceCounting.html#indirect-parameters" target="_blank">http://clang.llvm.org/<wbr>docs/<wbr>AutomaticReferenceCounting.<wbr>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>html incorrect, or are we just misunderstanding that document?</div><div><br>Thanks,</div><div>Nico</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 26, 2017 at 1:51 PM, Akira Hatanaka via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: ahatanak<br>
Date: Thu Jan 26 12:51:10 2017<br>
New Revision: 293199<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=293199&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject?rev=293199&view=rev</a><br>
Log:<br>
Turn on -Wblock-capture-autoreleasing by default.<br>
<br>
Turning on the warning by default helps the users as it's a common<br>
mistake to capture out-parameters in a block without ensuring the object<br>
assigned doesn't get released.<br>
<br>
<a>rdar://problem/30200058</a><br>
<br>
Modified:<br>
cfe/trunk/include/clang/Basic/<wbr>DiagnosticSemaKinds.td<br>
cfe/trunk/test/SemaObjC/arc.m<br>
<br>
Modified: cfe/trunk/include/clang/Basic/<wbr>DiagnosticSemaKinds.td<br>
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">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/include/clang/<wbr>Basic/DiagnosticSemaKinds.td?<wbr>rev=293199&r1=293198&r2=<wbr>293199&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/include/clang/Basic/<wbr>DiagnosticSemaKinds.td (original)<br>
+++ cfe/trunk/include/clang/Basic/<wbr>DiagnosticSemaKinds.td Thu Jan 26 12:51:10 2017<br>
@@ -5185,7 +5185,7 @@ def err_arc_inconsistent_property_<wbr>owners<br>
def warn_block_capture_autoreleasi<wbr>ng : Warning<<br>
"block captures an autoreleasing out-parameter, which may result in "<br>
"use-after-free bugs">,<br>
- InGroup<BlockCaptureAutoReleas<wbr>ing>, DefaultIgnore;<br>
+ InGroup<BlockCaptureAutoReleas<wbr>ing>;<br>
def note_declare_parameter_autorel<wbr>easing : Note<<br>
"declare the parameter __autoreleasing explicitly to suppress this warning">;<br>
def note_declare_parameter_strong : Note<<br>
<br>
Modified: cfe/trunk/test/SemaObjC/arc.m<br>
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">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/test/SemaObjC/<wbr>arc.m?rev=293199&r1=293198&r2=<wbr>293199&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/test/SemaObjC/arc.m (original)<br>
+++ cfe/trunk/test/SemaObjC/arc.m Thu Jan 26 12:51:10 2017<br>
@@ -1,4 +1,4 @@<br>
-// 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>
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -fblocks -verify -Wno-objc-root-class %s<br>
<br>
typedef unsigned long NSUInteger;<br>
typedef const void * CFTypeRef;<br>
<br>
<br>
______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>
</div></blockquote></div><br></div></div></div></blockquote></div><br></div>