<div dir="ltr">Dear all,<div><br></div><div>I wish to prevent the RetainCountChecker from analyzing function bodies if these functions have certain annotate attributes. Consider the following example to get a better idea of why I wish to do that.</div><div><br></div><div>Below is a small snippet from the Integer Set Library (ISL).</div><div><div></div><br><div><div class="gmail-hljs gmail-coffeescript" style="display:block;overflow-x:auto;padding:0.5em;background:rgb(248,248,248);font-family:monospace"><div style="color:rgb(51,51,51)"><div>typedef struct {</div><div>  int ref;</div><div>} isl_basic_map;</div></div><div style="color:rgb(51,51,51)"><br></div><div style="color:rgb(51,51,51)">__attribute__((cf_returns_retained))</div><div style="color:rgb(51,51,51)">isl_basic_map *isl_basic_map_copy(isl_basic_map *bmap);</div><div style="color:rgb(51,51,51)"><br></div><div style="color:rgb(51,51,51)">__attribute__((cf_returns_retained))</div><div style="color:rgb(51,51,51)">isl_basic_map *isl_basic_map_cow</div><div style="color:rgb(51,51,51)">(__attribute__((cf_consumed)) isl_basic_map *bmap);</div><div style="color:rgb(51,51,51)"><br></div><div style="color:rgb(51,51,51)">void free(void *);<br></div><div style="color:rgb(51,51,51)"><br></div><div style="color:rgb(51,51,51)">__attribute__((annotate(<span class="gmail-hljs-string" style="color:rgb(136,0,0)">"rc_ownership_trusted_implementation"</span>))) isl_basic_map *isl_basic_map_free</div><div style="color:rgb(51,51,51)">(__attribute__((cf_consumed)) isl_basic_map *bmap) {</div><div style="color:rgb(51,51,51)">  <span class="gmail-hljs-keyword" style="font-weight:bold">if</span> (!bmap)</div><div style="color:rgb(51,51,51)">    <span class="gmail-hljs-keyword" style="font-weight:bold">return</span> NULL;</div><div style="color:rgb(51,51,51)"><br></div><div style="color:rgb(51,51,51)">  <span class="gmail-hljs-keyword" style="font-weight:bold">if</span> (--bmap->ref > <span class="gmail-hljs-number" style="color:rgb(136,0,0)">0</span>)</div><div style="color:rgb(51,51,51)">    <span class="gmail-hljs-keyword" style="font-weight:bold">return</span> NULL;</div><div style="color:rgb(51,51,51)"><br></div><div style="color:rgb(51,51,51)">  free(bmap);</div><div style="color:rgb(51,51,51)">  <span class="gmail-hljs-keyword" style="font-weight:bold">return</span> NULL;</div><div style="color:rgb(51,51,51)">}</div><div style="color:rgb(51,51,51)"><br></div><div style="color:rgb(51,51,51)">__attribute__((cf_returns_retained))</div><div style="color:rgb(51,51,51)">isl_basic_map *foo</div><div style="color:rgb(51,51,51)">(__attribute__((cf_consumed)) isl_basic_map *bmap) {</div><div style="color:rgb(51,51,51)">  <span class="gmail-hljs-regexp" style="color:rgb(188,96,96)">//</span> <b>After <span class="gmail-hljs-keyword">this</span> call, <span class="gmail-hljs-string" style="color:rgb(136,0,0)">'temp'</span> has a +<span class="gmail-hljs-number" style="color:rgb(136,0,0)">1</span> reference count.</b></div><div style="color:rgb(51,51,51)">  isl_basic_map *temp = isl_basic_map_copy(bmap);</div><div style="color:rgb(51,51,51)">  <span class="gmail-hljs-regexp" style="color:rgb(188,96,96)">//</span> <b>After <span class="gmail-hljs-keyword">this</span> call, <span class="gmail-hljs-string" style="color:rgb(136,0,0)">'bmap'</span> has a +<span class="gmail-hljs-number" style="color:rgb(136,0,0)">1</span> reference count.</b></div><div><font color="#333333">  bmap = isl_basic_map_cow(bmap);</font></div><div style="color:rgb(51,51,51)">  <span class="gmail-hljs-regexp" style="color:rgb(188,96,96)">//</span> <b>After <span class="gmail-hljs-keyword">this</span> call, assuming the predicate <span class="gmail-hljs-keyword">of</span> the second <span class="gmail-hljs-keyword">if</span> branch to be <span class="gmail-hljs-literal" style="color:rgb(120,169,96)">true</span>, <span class="gmail-hljs-string" style="color:rgb(136,0,0)">'bmap'</span> has a +<span class="gmail-hljs-number" style="color:rgb(136,0,0)">1</span> reference count.</b></div><div style="color:rgb(51,51,51)">  isl_basic_map_free(bmap);</div><div style="color:rgb(51,51,51)">  <span class="gmail-hljs-keyword" style="font-weight:bold">return</span> temp; <b>// Object leaked: 'bmap'</b></div><div style="color:rgb(51,51,51)">}</div></div></div><br><div></div></div><div>While running the RetainCountChecker on the above example, it raises a leak warning for 'bmap' in function 'foo'. This warning is a true positive from the checker's perspective in the sense that the reference count of 'bmap' obtained from 'isl_basic_map_cow' is not decremented(from the checker's perspective) in 'isl_basic_map_free' even though it takes the argument 'bmap' as '__attribute__((cf_consumed))'.<br><br>Actually, '--bmap->ref' does decrement the reference count (from ISL's perspective). Hence, to prevent such false positives (from ISL's perspective) to be raised, I wish to prevent the RetainCountChecker to analyze the bodies of the functions having 'rc_ownership_trusted_implementation' annotate attribute. I want the checker to just look at the declaration of such functions (and not go inside their bodies) to get the necessary information about reference counting.</div><div><br></div><div>Could someone suggest me a way to achieve my objective?</div><div><br></div><div><br></div><div>Thank you.</div><div><br></div><div><br></div><div>Regards,</div><div>Malhar Thakkar</div></div><div hspace="streak-pt-mark" style="max-height:1px"><img alt="" style="width:0px;max-height:0px;overflow:hidden" src="https://mailfoogae.appspot.com/t?sender=aY3MxM2IxMDMxQGlpdGguYWMuaW4%3D&type=zerocontent&guid=d5488588-0dcc-4980-a8f9-243fdd2af96a"><font color="#ffffff" size="1">ᐧ</font></div>