forked from OSchip/llvm-project
[clang-tidy docs] Move option descriptions to the Options section
+ random fixes llvm-svn: 279115
This commit is contained in:
parent
cc29958fb8
commit
0f85498a0b
|
@ -9,7 +9,8 @@ The condition of ``assert()`` is evaluated only in debug builds so a
|
|||
condition with side effect can cause different behavior in debug / release
|
||||
builds.
|
||||
|
||||
There are two options:
|
||||
Options
|
||||
-------
|
||||
|
||||
.. option:: AssertMacros
|
||||
|
||||
|
|
|
@ -3,15 +3,11 @@
|
|||
misc-dangling-handle
|
||||
====================
|
||||
|
||||
Detect dangling references in value handlers like
|
||||
Detect dangling references in value handles like
|
||||
``std::experimental::string_view``.
|
||||
These dangling references can come from constructing handles from temporary
|
||||
These dangling references can be a result of constructing handles from temporary
|
||||
values, where the temporary is destroyed soon after the handle is created.
|
||||
|
||||
By default only ``std::experimental::basic_string_view`` is considered.
|
||||
This list can be modified by passing a `;` separated list of class names using
|
||||
the HandleClasses option.
|
||||
|
||||
Examples:
|
||||
|
||||
.. code-block:: c++
|
||||
|
@ -32,3 +28,11 @@ Examples:
|
|||
char Array[10]{};
|
||||
return Array;
|
||||
}
|
||||
|
||||
Options
|
||||
-------
|
||||
|
||||
.. option:: HandleClasses
|
||||
|
||||
A semicolon-separated list of class names that should be treated as handles.
|
||||
By default only ``std::experimental::basic_string_view`` is considered.
|
||||
|
|
|
@ -13,12 +13,11 @@ because replacing ``insert`` with ``emplace`` may result in
|
|||
`speed regression <http://htmlpreview.github.io/?https://github.com/HowardHinnant/papers/blob/master/insert_vs_emplace.html>`_, but it might get support with some addition flag in the future.
|
||||
|
||||
By default only ``std::vector``, ``std::deque``, ``std::list`` are considered.
|
||||
This list can be modified by passing a semicolon-separated list of class names
|
||||
using the `ContainersWithPushBack` option.
|
||||
This list can be modified using the :option:`ContainersWithPushBack` option.
|
||||
|
||||
Before:
|
||||
|
||||
.. code:: c++
|
||||
.. code-block:: c++
|
||||
|
||||
std::vector<MyClass> v;
|
||||
v.push_back(MyClass(21, 37));
|
||||
|
@ -30,7 +29,7 @@ Before:
|
|||
|
||||
After:
|
||||
|
||||
.. code:: c++
|
||||
.. code-block:: c++
|
||||
|
||||
std::vector<MyClass> v;
|
||||
v.emplace_back(21, 37);
|
||||
|
@ -45,14 +44,14 @@ inside a container.
|
|||
|
||||
Before:
|
||||
|
||||
.. code:: c++
|
||||
.. code-block:: c++
|
||||
|
||||
std::vector<boost::optional<std::string> > v;
|
||||
v.push_back("abc");
|
||||
|
||||
After:
|
||||
|
||||
.. code:: c++
|
||||
.. code-block:: c++
|
||||
|
||||
std::vector<boost::optional<std::string> > v;
|
||||
v.emplace_back("abc");
|
||||
|
@ -62,7 +61,7 @@ In some cases the transformation would be valid, but the code
|
|||
wouldn't be exception safe.
|
||||
In this case the calls of ``push_back`` won't be replaced.
|
||||
|
||||
.. code:: c++
|
||||
.. code-block:: c++
|
||||
|
||||
std::vector<std::unique_ptr<int>> v;
|
||||
v.push_back(std::unique_ptr<int>(new int(0)));
|
||||
|
@ -70,16 +69,15 @@ In this case the calls of ``push_back`` won't be replaced.
|
|||
v.push_back(std::unique_ptr<int>(ptr));
|
||||
|
||||
This is because replacing it with ``emplace_back`` could cause a leak of this
|
||||
pointer if ``emplace_back`` would throw exception before emplacement
|
||||
(e.g. not enough memory to add new element).
|
||||
pointer if ``emplace_back`` would throw exception before emplacement (e.g. not
|
||||
enough memory to add new element).
|
||||
|
||||
For more info read item 42 - "Consider emplacement instead of insertion."
|
||||
of Scott Meyers Effective Modern C++.
|
||||
For more info read item 42 - "Consider emplacement instead of insertion." of
|
||||
Scott Meyers Effective Modern C++.
|
||||
|
||||
The default smart pointers that are considered are
|
||||
``std::unique_ptr``, ``std::shared_ptr``, ``std::auto_ptr``.
|
||||
To specify other smart pointers or other classes use option
|
||||
`SmartPointers` similar to `ContainersWithPushBack`.
|
||||
The default smart pointers that are considered are ``std::unique_ptr``,
|
||||
``std::shared_ptr``, ``std::auto_ptr``. To specify other smart pointers or
|
||||
other classes use the :option:`SmartPointers` option.
|
||||
|
||||
|
||||
Check also fires if any argument of constructor call would be:
|
||||
|
@ -88,3 +86,15 @@ Check also fires if any argument of constructor call would be:
|
|||
or if the argument would be converted via derived-to-base cast.
|
||||
|
||||
This check requires C++11 of higher to run.
|
||||
|
||||
Options
|
||||
-------
|
||||
|
||||
.. option:: ContainersWithPushBack
|
||||
|
||||
Semicolon-separated list of class names of custom containers that support
|
||||
``push_back``.
|
||||
|
||||
.. option:: SmartPointers
|
||||
|
||||
Semicolon-separated list of class names of custom smart pointers.
|
||||
|
|
Loading…
Reference in New Issue