Skip to content

Commit

Permalink
[analyzer][docs] Ellaborate the docs of cplusplus.StringChecker
Browse files Browse the repository at this point in the history
Let's describe accurately what the users can expect from the checker in
a direct way.
Also, add an example warning message.

Reviewed By: martong, Szelethus

Differential Revision: https://reviews.llvm.org/D113401
  • Loading branch information
Balazs Benics committed Nov 19, 2021
1 parent b8207db commit bf55b9f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion clang/docs/analyzer/checkers.rst
Expand Up @@ -319,13 +319,22 @@ cplusplus.StringChecker (C++)
"""""""""""""""""""""""""""""
Checks std::string operations.
Checks if the cstring pointer from which the ``std::string`` object is
constructed is ``NULL`` or not.
If the checker cannot reason about the nullness of the pointer it will assume
that it was non-null to satisfy the precondition of the constructor.
This checker is capable of checking the `SEI CERT C++ coding rule STR51-CPP.
Do not attempt to create a std::string from a null pointer
<https://wiki.sei.cmu.edu/confluence/x/E3s-BQ>`__.
.. code-block:: cpp
#include <string>
void f(const char *p) {
if (!p) {
std::string msg(p); // warn: p is NULL
std::string msg(p); // warn: The parameter must not be null
}
}
Expand Down

0 comments on commit bf55b9f

Please sign in to comment.