<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 4:27 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; "><br><div><div>On Jul 27, 2012, at 16:23 , jahanian <<a href="mailto:fjahanian@apple.com">fjahanian@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div 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="">  </span>// Require a CF*Ref return type.</div><div style="margin: 0px; color: rgb(49, 89, 93); "><span style="">  </span><span style="color: #bb2ca2">if</span><span style=""> (!</span>isCFType<span style="">(fn-></span>getResultType<span style="">()))</span></div><div style="margin: 0px; color: rgb(49, 89, 93); "><span style="">    </span><span style="color: #bb2ca2">return</span><span style=""> </span>ACC_invalid<span style="">;</span></div><div style="margin: 0px; color: rgb(49, 89, 93); "><span style=""><br></span></div><div style="margin: 0px; color: rgb(49, 89, 93); "><span style="">  </span><span style="color: #bb2ca2">if</span><span style=""> (!</span>isAnyRetainable<span style="">(</span><span style="color: #4f8187">TargetClass</span><span style="">))</span></div><div style="margin: 0px; color: rgb(49, 89, 93); "><span style="">    </span><span style="color: #bb2ca2">return</span><span style=""> </span>ACC_invalid<span style="">;</span></div><div style="margin: 0px; color: rgb(0, 132, 0); "><span style=""><br></span></div><div style="margin: 0px; color: rgb(0, 132, 0); "><span style="">  </span>// Honor an explicit 'not retained' attribute.</div><div style="margin: 0px; color: rgb(112, 61, 170); "><span style="">  </span><span style="color: #bb2ca2">if</span><span style=""> (fn-></span><span style="color: #31595d">hasAttr</span><span style=""><</span>CFReturnsNotRetainedAttr<span style="">>())</span></div><div style="margin: 0px; color: rgb(49, 89, 93); "><span style="">    </span><span style="color: #bb2ca2">return</span><span style=""> </span>ACC_plusZero<span style="">;</span></div><div style="margin: 0px; color: rgb(0, 132, 0); "><span style=""><br></span></div><div style="margin: 0px; color: rgb(0, 132, 0); "><span style="">  </span>// Honor an explicit 'retained' attribute, except that for</div><div style="margin: 0px; color: rgb(0, 132, 0); "><span style="">  </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="">  </span>// because it's a bit frightening.</div><div style="margin: 0px; color: rgb(112, 61, 170); "><span style="">  </span><span style="color: #bb2ca2">if</span><span style=""> (fn-></span><span style="color: #31595d">hasAttr</span><span style=""><</span>CFReturnsRetainedAttr<span style="">>())</span></div><div style="margin: 0px; color: rgb(0, 132, 0); "><span style="">    </span><span style="color: #bb2ca2">return</span><span style=""> </span><span style="color: #31595d">ACC_invalid</span><span style="">; </span>// ACC_plusOne if we start accepting this</div><div style="margin: 0px; color: rgb(0, 132, 0); "><span style=""><br></span></div><div style="margin: 0px; color: rgb(0, 132, 0); "><span style="">  </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="">  </span><span style="color: #bb2ca2">if</span><span style=""> (builtinID == </span><span style="color: #4f8187">Builtin</span><span style="">::</span>BI__builtin___CFStringMakeConstantString<span style="">)</span></div><div style="margin: 0px; color: rgb(49, 89, 93); "><span style="">    </span><span style="color: #bb2ca2">return</span><span style=""> </span>ACC_bottom<span style="">;</span></div><div style="margin: 0px; color: rgb(0, 132, 0); "><span style=""><br></span></div><div style="margin: 0px; color: rgb(0, 132, 0); "><span style="">  </span>// Otherwise, don't do anything implicit with an unaudited function.</div><div style="margin: 0px; color: rgb(112, 61, 170); "><span style="">  </span><span style="color: #bb2ca2">if</span><span style=""> (!fn-></span><span style="color: #31595d">hasAttr</span><span style=""><</span>CFAuditedTransferAttr<span style="">>())</span></div><div style="margin: 0px; color: rgb(49, 89, 93); "><span style="">    </span><span style="color: #bb2ca2">return</span><span style=""> </span>ACC_invalid<span style="">;</span></div><div style="margin: 0px; color: rgb(0, 132, 0); "><span style=""><br></span></div><div style="margin: 0px; color: rgb(0, 132, 0); "><span style="">  </span>// Otherwise, it's +0 unless it follows the create convention.</div><div style="margin: 0px; color: rgb(79, 129, 135); "><span style="">  </span><span style="color: #bb2ca2">if</span><span style=""> (</span>ento<span style="">::</span>coreFoundation<span style="">::</span><span style="color: #31595d">followsCreateRule</span><span style="">(fn))</span></div><div style="margin: 0px; color: rgb(0, 132, 0); "><span style="">    </span><span style="color: #bb2ca2">return</span><span style=""> </span><span style="color: #31595d">ACC_invalid</span><span style="">; </span>// ACC_plusOne if we start accepting this</div><div style="margin: 0px; color: rgb(49, 89, 93); "><span style=""><br></span></div><div style="margin: 0px; color: rgb(49, 89, 93); "><span style="">  </span><span style="color: #bb2ca2">return</span><span style=""> </span>ACC_plusZero<span style="">;</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></blockquote><div><br></div><div>That's intentional. In our real headers, we have CFAuditedTransferAttrs on all parts of CoreFoundation that are guaranteed to correctly follow the naming conventions. CFDictionary.h, for example, is now bracketed in <span style="font-family: Menlo; font-size: 11px; color: rgb(120, 73, 42); ">_Pragma(</span><span style="color: rgb(209, 47, 27); font-family: Menlo; font-size: 11px; ">"clang arc_cf_code_audited begin"</span><span style="font-family: Menlo; font-size: 11px; color: rgb(120, 73, 42); ">)</span> / <span style="font-family: Menlo; font-size: 11px; color: rgb(120, 73, 42); ">_Pragma(</span><span style="color: rgb(209, 47, 27); font-family: Menlo; font-size: 11px; ">"clang arc_cf_code_audited end"</span><span style="font-family: Menlo; font-size: 11px; color: rgb(120, 73, 42); ">)</span>, which implicitly adds the attribute to everything in between. We should probably have this in our fixit test cases.</div></div></div></blockquote><div><br></div>OK, good to know.</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><div><br></div></div>Jordan</div></blockquote></div><br></body></html>