Skip to content

Commit cbb67b5

Browse files
committed
[www] Add analyzer FAQ about not releasing ivars in -dealloc.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@279183 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 1319614 commit cbb67b5

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

www/analyzer/faq.html

+10
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ <h1>FAQ and How to Deal with Common False Positives</h1>
2929
<li><a href="#dead_store">How do I tell the static analyzer that I don't care about a specific dead store?</a></li>
3030
<li><a href="#unused_ivar">How do I tell the static analyzer that I don't care about a specific unused instance variable in Objective C?</a></li>
3131
<li><a href="#unlocalized_string">How do I tell the static analyzer that I don't care about a specific unlocalized string?</a></li>
32+
<li><a href="#dealloc_mrr">How do I tell the analyzer that my instance variable does not need to be released in -dealloc under Manual Retain/Release?</a></li>
3233
<li><a href="#use_assert">The analyzer assumes that a loop body is never entered. How can I tell it that the loop body will be entered at least once?</a></li>
3334
<li><a href="#suppress_issue">How can I suppress a specific analyzer warning?</a></li>
3435
<li><a href="#exclude_code">How can I selectively exclude code the analyzer examines?</a></li>
@@ -105,6 +106,15 @@ <h4 id="unlocalized_string" class="faq">Q: How do I tell the static analyzer tha
105106
</pre>
106107
</p>
107108

109+
<h4 id="dealloc_mrr" class="faq">Q: How do I tell the analyzer that my instance variable does not need to be released in -dealloc under Manual Retain/Release?</h4>
110+
111+
<p>If your class only uses an instance variable for part of its lifetime, it may
112+
maintain an invariant guaranteeing that the instance variable is always released
113+
before -dealloc. In this case, you can silence a warning about a missing release
114+
by either adding <tt>assert(_ivar == nil)</tt> or an explicit release
115+
<tt>[_ivar release]</tt> (which will be a no-op when the variable is nil) in
116+
-dealloc. </p>
117+
108118
<h4 id="use_assert" class="faq">Q: The analyzer assumes that a loop body is never entered. How can I tell it that the loop body will be entered at least once?</h4>
109119

110120
<img src="images/example_use_assert.png" alt="example use assert">

0 commit comments

Comments
 (0)