================
@@ -265,8 +266,75 @@ it refers to has gone out of scope.
p = &i; // OK!
}
(void)*p;
+ }
+
+The analysis also covers pointer arithmetic. If the result of pointer
+arithmetic refers to an object whose lifetime has ended, the analysis diagnoses
+the later use.
+
+.. code-block:: c++
+
+ void pointer_arithmetic() {
+ int *p;
+ {
+ int data[4] = {};
+ p = data + 1; // warning: object whose reference is captured does not
live long enough
+ } // note: destroyed here
+ (void)*p; // note: later used here
+ }
+
+Use after free
+--------------
+
+This check warns when a pointer or reference is used after the object it refers
+to has been freed with ``delete`` or ``delete[]``. Heap allocations created
with
+``new`` are checked so that pointers, references and views to the allocation
are
+not used after the object is deleted.
----------------
Xazax-hun wrote:
```suggestion
to has been freed with ``delete`` or ``delete[]``. Heap allocations created with
``new`` are checked.
```
I think the last part is not adding new information, just repeating what was
already communicated in the first sentence.
https://github.com/llvm/llvm-project/pull/196790
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits