This revision was automatically updated to reflect the committed changes. Closed by commit rGbf55b9f0d0e9: [analyzer][docs] Ellaborate the docs of cplusplus.StringChecker (authored by steakhal). Herald added a project: clang. Herald added a subscriber: cfe-commits.
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D113401/new/ https://reviews.llvm.org/D113401 Files: clang/docs/analyzer/checkers.rst Index: clang/docs/analyzer/checkers.rst =================================================================== --- clang/docs/analyzer/checkers.rst +++ clang/docs/analyzer/checkers.rst @@ -319,13 +319,22 @@ """"""""""""""""""""""""""""" 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 } }
Index: clang/docs/analyzer/checkers.rst =================================================================== --- clang/docs/analyzer/checkers.rst +++ clang/docs/analyzer/checkers.rst @@ -319,13 +319,22 @@ """"""""""""""""""""""""""""" 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