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
+44Lines changed: 44 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3476,6 +3476,24 @@ Limitations:
3476
3476
alpha.WebKit
3477
3477
^^^^^^^^^^^^
3478
3478
3479
+
alpha.webkit.ForwardDeclChecker
3480
+
"""""""""""""""""""""""""""""""
3481
+
Check for local variables, member variables, and function arguments that are forward declared.
3482
+
3483
+
.. code-block:: cpp
3484
+
3485
+
struct Obj;
3486
+
Obj* provide();
3487
+
3488
+
struct Foo {
3489
+
Obj* ptr; // warn
3490
+
};
3491
+
3492
+
void foo() {
3493
+
Obj* obj = provide(); // warn
3494
+
consume(obj); // warn
3495
+
}
3496
+
3479
3497
.. _alpha-webkit-NoUncheckedPtrMemberChecker:
3480
3498
3481
3499
alpha.webkit.MemoryUnsafeCastChecker
@@ -3642,6 +3660,12 @@ The goal of this rule is to make sure that lifetime of any dynamically allocated
3642
3660
3643
3661
The rules of when to use and not to use CheckedPtr / CheckedRef are same as alpha.webkit.UncountedCallArgsChecker for ref-counted objects.
3644
3662
3663
+
alpha.webkit.UnretainedCallArgsChecker
3664
+
""""""""""""""""""""""""""""""""""""""
3665
+
The goal of this rule is to make sure that lifetime of any dynamically allocated NS or CF objects passed as a call argument keeps its memory region past the end of the call. This applies to call to any function, method, lambda, function pointer or functor. NS or CF objects aren't supposed to be allocated on stack so we check arguments for parameters of raw pointers and references to unretained types.
3666
+
3667
+
The rules of when to use and not to use RetainPtr are same as alpha.webkit.UncountedCallArgsChecker for ref-counted objects.
3668
+
3645
3669
alpha.webkit.UncountedLocalVarsChecker
3646
3670
""""""""""""""""""""""""""""""""""""""
3647
3671
The goal of this rule is to make sure that any uncounted local variable is backed by a ref-counted object with lifetime that is strictly larger than the scope of the uncounted local variable. To be on the safe side we require the scope of an uncounted variable to be embedded in the scope of ref-counted object that backs it.
@@ -3773,6 +3797,26 @@ Here are some examples of situations that we warn about as they *might* be poten
3773
3797
NSObject* unretained = retained.get(); // warn
3774
3798
}
3775
3799
3800
+
webkit.RetainPtrCtorAdoptChecker
3801
+
""""""""""""""""""""""""""""""""
3802
+
The goal of this rule is to make sure the constructor of RetainPtr as well as adoptNS and adoptCF are used correctly.
3803
+
When creating a RetainPtr with +1 semantics, adoptNS or adoptCF should be used, and in +0 semantics, RetainPtr constructor should be used.
3804
+
Warn otherwise.
3805
+
3806
+
These are examples of cases that we consider correct:
3807
+
3808
+
.. code-block:: cpp
3809
+
3810
+
RetainPtr ptr = adoptNS([[NSObject alloc] init]); // ok
3811
+
RetainPtr ptr = CGImageGetColorSpace(image); // ok
3812
+
3813
+
Here are some examples of cases that we consider incorrect use of RetainPtr constructor and adoptCF
3814
+
3815
+
.. code-block:: cpp
3816
+
3817
+
RetainPtr ptr = [[NSObject alloc] init]; // warn
3818
+
auto ptr = adoptCF(CGImageGetColorSpace(image)); // warn
0 commit comments