You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: clang/docs/analyzer/checkers.rst
+39Lines changed: 39 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3674,6 +3674,45 @@ The goal of this rule is to make sure that any NS or CF local variable is backed
3674
3674
3675
3675
The rules of when to use and not to use RetainPtr are same as alpha.webkit.UncountedCallArgsChecker for ref-counted objects.
3676
3676
3677
+
These are examples of cases that we consider safe:
3678
+
3679
+
.. code-block:: cpp
3680
+
3681
+
void foo1() {
3682
+
RetainPtr<NSObject> retained;
3683
+
// The scope of unretained is EMBEDDED in the scope of retained.
3684
+
{
3685
+
NSObject* unretained = retained.get(); // ok
3686
+
}
3687
+
}
3688
+
3689
+
void foo2(RetainPtr<NSObject> retained_param) {
3690
+
NSObject* unretained = retained_param.get(); // ok
3691
+
}
3692
+
3693
+
void FooClass::foo_method() {
3694
+
NSObject* unretained = this; // ok
3695
+
}
3696
+
3697
+
Here are some examples of situations that we warn about as they *might* be potentially unsafe. The logic is that either we're able to guarantee that a local variable is safe or it's considered unsafe.
0 commit comments