Author: Balazs Benics Date: 2021-11-19T11:59:46+01:00 New Revision: bf55b9f0d0e938def5d24629325b271cbfc3b04a
URL: https://github.com/llvm/llvm-project/commit/bf55b9f0d0e938def5d24629325b271cbfc3b04a DIFF: https://github.com/llvm/llvm-project/commit/bf55b9f0d0e938def5d24629325b271cbfc3b04a.diff LOG: [analyzer][docs] Ellaborate the docs of cplusplus.StringChecker 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 Added: Modified: clang/docs/analyzer/checkers.rst Removed: ################################################################################ diff --git a/clang/docs/analyzer/checkers.rst b/clang/docs/analyzer/checkers.rst index 80cf3bc7c313..df62fb0643f8 100644 --- a/clang/docs/analyzer/checkers.rst +++ b/clang/docs/analyzer/checkers.rst @@ -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 } } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits