[llvm-branch-commits] [clang] [analyzer] Rename DanglingPtrDeref to StackUseAfterScope and move it to core (PR #233889)
Balázs Benics via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Oct 21 04:10:40 PDT 2026
================
@@ -3195,66 +3251,6 @@ void test() {
}
```
-(alpha-core-danglingptrderef)=
-
-#### alpha.core.DanglingPtrDeref (C, C++)
-
-Check for dereferences of pointers that refer to an object whose
-lifetime has already ended. Such a pointer is dangling. The checker
-reports it when it is dereferenced and when it is passed to a function.
-A return statement that does not dereference the pointer does not lead to a report.
-Such a case is reported by the {ref}`core-StackAddressEscape` checker.
-
-Each object is reported at most once on an execution path. If the same dangling
-pointer is used several times then only the first use is reported. Setting the pointer
-to null when the object goes out of scope avoids the dangling pointer and suppresses
-the report.
-
-```cpp
-void test_deref() {
- int *ptr = 0;
- {
- int num = 5;
- ptr = #
- } // note: 'num' is destroyed here
- *ptr = 6; // warn: use of 'num' after its lifetime ended
-}
-
-void test_in_scope() {
- int num = 5;
- int *ptr = #
- {
- *ptr = 6; // no warning, 'num' is still in scope
- }
-}
-```
-
-The `-analyzer-config cfg-lifetime=true` option is a prerequisite for these
-reports. Without it the checker does not report anything and no error is emitted
-by the analyzer.
----------------
steakhal wrote:
Can you move mentions of the `cfg-lifetime` to the parent PR where we enable that by default?
That said, that this slipped in here, I think you should audit all of the spellings of this CFG option and update them appropriately.
https://github.com/llvm/llvm-project/pull/233889
More information about the llvm-branch-commits
mailing list