<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="">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=""><br class=""></div><div><blockquote type="cite" class=""><div class="">On Feb 11, 2017, at 11:54 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="">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-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" class="">http://clang.llvm.org/docs/AutomaticReferenceCounting.html#indirect-parameters</a> suggests NSError ** should "be implicitly qualified with __autoreleasing." Is that a bug in the implementation of the warning, is AutomaticReferenceCounting.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-<wbr class="">project?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 href="rdar://problem/30200058" 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-<wbr class="">project/cfe/trunk/include/<wbr class="">clang/Basic/<wbr class="">DiagnosticSemaKinds.td?rev=<wbr class="">293199&r1=293198&r2=293199&<wbr class="">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_<wbr class="">autoreleasing : Warning<<br class="">
   "block captures an autoreleasing out-parameter, which may result in "<br class="">
   "use-after-free bugs">,<br class="">
-  InGroup<<wbr class="">BlockCaptureAutoReleasing>, DefaultIgnore;<br class="">
+  InGroup<<wbr class="">BlockCaptureAutoReleasing>;<br class="">
 def note_declare_parameter_<wbr class="">autoreleasing : 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-<wbr class="">project/cfe/trunk/test/<wbr class="">SemaObjC/arc.m?rev=293199&r1=<wbr class="">293198&r2=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" 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=""></body></html>