Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NFC][analyzer][docs] Restore/remove orphaned images #122481

Merged
merged 2 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions clang/docs/analyzer/user-docs/FAQ.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ 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?

.. image:: ../images/example_custom_assert.png

You can tell the analyzer that this path is unreachable by teaching it about your `custom assertion handlers <Annotations.html#custom-assertion-handlers>`__. For example, you can modify the code segment as following:

.. code-block:: c
Expand All @@ -25,6 +27,8 @@ 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?

.. image:: ../images/example_null_pointer.png

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
Expand Down Expand Up @@ -143,6 +147,8 @@ Ensuring Loop Body Execution

Q: The analyzer assumes that a loop body is never entered. How can I tell it that the loop body will be entered at least once?

.. image:: ../images/example_use_assert.png

In cases where you know that a loop will always be entered at least once, you can use assertions to inform the analyzer. For example:

.. code-block:: c
Expand Down
Binary file removed clang/www/analyzer/images/scan_build_cmd.png
Binary file not shown.
Loading