================
@@ -0,0 +1,208 @@
+FAQ and How to Deal with Common False Positives
+===============================================
+
+.. contents::
+ :local:
+
+Custom Assertions
+-----------------
+
+Q: How do I tell the analyzer that I do not want the bug being reported here
since my custom error handler will safely end the execution before the bug is
reached?
+
+You can tell the analyzer that this path is unreachable by teaching it about
your `custom assertion handlers <annotations.html#custom_assertions>`_. For
example, you can modify the code segment as following:
+
+.. code-block:: c
+
+ void customAssert() __attribute__((analyzer_noreturn));
+ int foo(int *b) {
+ if (!b)
+ customAssert();
+ return *b;
+ }
+
+Null Pointer Dereference
+------------------------
+
+Q: The analyzer reports a null dereference, but I know that the pointer is
never null. How can I tell the analyzer that a pointer can never be null?
+
+The reason the analyzer often thinks that a pointer can be null is because the
preceding code checked compared it against null. If you are absolutely sure
that it cannot be null, remove the preceding check and, preferably, add an
assertion as well. For example:
+
+.. code-block:: c
+
+ void usePointer(int *b);
+ int foo(int *b) {
+ usePointer(b);
+ return *b;
+ }
----------------
NagyDonat wrote:
I don't see how is this an example of the preceding text...
https://github.com/llvm/llvm-project/pull/112831
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits