<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Jul 27, 2012, at 3:49 PM, Jordan Rose wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><meta http-equiv="Content-Type" content="text/html charset=us-ascii"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Hm. Here's that whole function (before the change):</div><div><br></div><div><div style="margin: 0px; font-size: 11px; font-family: Menlo; "><div style="margin: 0px; "><span style="color: #4f8187">ACCResult</span> checkCallToFunction(<span style="color: #4f8187">FunctionDecl</span> *fn) {</div><div style="margin: 0px; color: rgb(0, 132, 0); "><span style="color: #000000">  </span>// Require a CF*Ref return type.</div><div style="margin: 0px; color: rgb(49, 89, 93); "><span style="color: #000000">  </span><span style="color: #bb2ca2">if</span><span style="color: #000000"> (!</span>isCFType<span style="color: #000000">(fn-></span>getResultType<span style="color: #000000">()))</span></div><div style="margin: 0px; color: rgb(49, 89, 93); "><span style="color: #000000">    </span><span style="color: #bb2ca2">return</span><span style="color: #000000"> </span>ACC_invalid<span style="color: #000000">;</span></div><div style="margin: 0px; color: rgb(49, 89, 93); "><span style="color: #000000"><br></span></div><div style="margin: 0px; color: rgb(49, 89, 93); "><span style="color: #000000">  </span><span style="color: #bb2ca2">if</span><span style="color: #000000"> (!</span>isAnyRetainable<span style="color: #000000">(</span><span style="color: #4f8187">TargetClass</span><span style="color: #000000">))</span></div><div style="margin: 0px; color: rgb(49, 89, 93); "><span style="color: #000000">    </span><span style="color: #bb2ca2">return</span><span style="color: #000000"> </span>ACC_invalid<span style="color: #000000">;</span></div><div style="margin: 0px; color: rgb(0, 132, 0); "><span style="color: #000000"><br></span></div><div style="margin: 0px; color: rgb(0, 132, 0); "><span style="color: #000000">  </span>// Honor an explicit 'not retained' attribute.</div><div style="margin: 0px; color: rgb(112, 61, 170); "><span style="color: #000000">  </span><span style="color: #bb2ca2">if</span><span style="color: #000000"> (fn-></span><span style="color: #31595d">hasAttr</span><span style="color: #000000"><</span>CFReturnsNotRetainedAttr<span style="color: #000000">>())</span></div><div style="margin: 0px; color: rgb(49, 89, 93); "><span style="color: #000000">    </span><span style="color: #bb2ca2">return</span><span style="color: #000000"> </span>ACC_plusZero<span style="color: #000000">;</span></div><div style="margin: 0px; color: rgb(0, 132, 0); "><span style="color: #000000"><br></span></div><div style="margin: 0px; color: rgb(0, 132, 0); "><span style="color: #000000">  </span>// Honor an explicit 'retained' attribute, except that for</div><div style="margin: 0px; color: rgb(0, 132, 0); "><span style="color: #000000">  </span>// now we're not going to permit implicit handling of +1 results,</div><div style="margin: 0px; color: rgb(0, 132, 0); "><span style="color: #000000">  </span>// because it's a bit frightening.</div><div style="margin: 0px; color: rgb(112, 61, 170); "><span style="color: #000000">  </span><span style="color: #bb2ca2">if</span><span style="color: #000000"> (fn-></span><span style="color: #31595d">hasAttr</span><span style="color: #000000"><</span>CFReturnsRetainedAttr<span style="color: #000000">>())</span></div><div style="margin: 0px; color: rgb(0, 132, 0); "><span style="color: #000000">    </span><span style="color: #bb2ca2">return</span><span style="color: #000000"> </span><span style="color: #31595d">ACC_invalid</span><span style="color: #000000">; </span>// ACC_plusOne if we start accepting this</div><div style="margin: 0px; color: rgb(0, 132, 0); "><span style="color: #000000"><br></span></div><div style="margin: 0px; color: rgb(0, 132, 0); "><span style="color: #000000">  </span>// Recognize this specific builtin function, which is used by CFSTR.</div><div style="margin: 0px; ">  <span style="color: #bb2ca2">unsigned</span> builtinID = fn-><span style="color: #31595d">getBuiltinID</span>();</div><div style="margin: 0px; color: rgb(49, 89, 93); "><span style="color: #000000">  </span><span style="color: #bb2ca2">if</span><span style="color: #000000"> (builtinID == </span><span style="color: #4f8187">Builtin</span><span style="color: #000000">::</span>BI__builtin___CFStringMakeConstantString<span style="color: #000000">)</span></div><div style="margin: 0px; color: rgb(49, 89, 93); "><span style="color: #000000">    </span><span style="color: #bb2ca2">return</span><span style="color: #000000"> </span>ACC_bottom<span style="color: #000000">;</span></div><div style="margin: 0px; color: rgb(0, 132, 0); "><span style="color: #000000"><br></span></div><div style="margin: 0px; color: rgb(0, 132, 0); "><span style="color: #000000">  </span>// Otherwise, don't do anything implicit with an unaudited function.</div><div style="margin: 0px; color: rgb(112, 61, 170); "><span style="color: #000000">  </span><span style="color: #bb2ca2">if</span><span style="color: #000000"> (!fn-></span><span style="color: #31595d">hasAttr</span><span style="color: #000000"><</span>CFAuditedTransferAttr<span style="color: #000000">>())</span></div><div style="margin: 0px; color: rgb(49, 89, 93); "><span style="color: #000000">    </span><span style="color: #bb2ca2">return</span><span style="color: #000000"> </span>ACC_invalid<span style="color: #000000">;</span></div><div style="margin: 0px; color: rgb(0, 132, 0); "><span style="color: #000000"><br></span></div><div style="margin: 0px; color: rgb(0, 132, 0); "><span style="color: #000000">  </span>// Otherwise, it's +0 unless it follows the create convention.</div><div style="margin: 0px; color: rgb(79, 129, 135); "><span style="color: #000000">  </span><span style="color: #bb2ca2">if</span><span style="color: #000000"> (</span>ento<span style="color: #000000">::</span>coreFoundation<span style="color: #000000">::</span><span style="color: #31595d">followsCreateRule</span><span style="color: #000000">(fn))</span></div><div style="margin: 0px; color: rgb(0, 132, 0); "><span style="color: #000000">    </span><span style="color: #bb2ca2">return</span><span style="color: #000000"> </span><span style="color: #31595d">ACC_invalid</span><span style="color: #000000">; </span>// ACC_plusOne if we start accepting this</div><div style="margin: 0px; color: rgb(49, 89, 93); "><span style="color: #000000"><br></span></div><div style="margin: 0px; color: rgb(49, 89, 93); "><span style="color: #000000">  </span><span style="color: #bb2ca2">return</span><span style="color: #000000"> </span>ACC_plusZero<span style="color: #000000">;</span></div><div style="margin: 0px; ">}</div></div></div><div><br></div><div>I wonder if leaving the "followsCreateRule" after the CFAuditedTransferAttr check would be better; relying on the naming convention for un-audited code may be a bad idea even</div></div></blockquote><div><br></div>If I leave it after, then CFAuditedTransferAttr check would not get me to check for the naming convention. Note that since in the non-diagnose case they both return</div><div>ACC_invalid, this will not change the behavior.</div><div><br><br><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div> for fixits. On the other hand, we can go ahead and turn on the CFReturnsRetainedAttr case (for diagnostics only, of course), since if that attribute was added the semantics of the function have implicitly been audited.</div></div></blockquote>OK.</div><div><br><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><br></div><div>On the plus side, you should be able to check for ACC_plusZero as well, and only suggest __bridge in that case.</div></div></blockquote>OK.</div><div><br></div><div>- Fariborz</div><div><br><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><br></div><br></div></blockquote></div><br></body></html>