linux-packaging-mono/external/llvm-project/clang-tools-extra/docs/clang-tidy/checks/google-runtime-member-string-references.rst
Xamarin Public Jenkins (auto-signing) 468663ddbb Imported Upstream version 6.10.0.49
Former-commit-id: 1d6753294b2993e1fbf92de9366bb9544db4189b
2020-01-16 16:38:04 +00:00

26 lines
757 B
ReStructuredText

.. title:: clang-tidy - google-runtime-member-string-references
google-runtime-member-string-references
=======================================
Finds members of type ``const string&``.
const string reference members are generally considered unsafe as they can be
created from a temporary quite easily.
.. code-block:: c++
struct S {
S(const string &Str) : Str(Str) {}
const string &Str;
};
S instance("string");
In the constructor call a string temporary is created from ``const char *`` and
destroyed immediately after the call. This leaves around a dangling reference.
This check emit warnings for both ``std::string`` and ``::string`` const
reference members.
Corresponding cpplint.py check name: `runtime/member_string_reference`.