From 0f85498a0b6cf1e4a4c8ce3d49b2f6f1a83c361e Mon Sep 17 00:00:00 2001 From: Alexander Kornienko Date: Thu, 18 Aug 2016 18:43:47 +0000 Subject: [PATCH] [clang-tidy docs] Move option descriptions to the Options section + random fixes llvm-svn: 279115 --- .../checks/misc-assert-side-effect.rst | 3 +- .../checks/misc-dangling-handle.rst | 16 +++++--- .../checks/modernize-use-emplace.rst | 40 ++++++++++++------- 3 files changed, 37 insertions(+), 22 deletions(-) diff --git a/clang-tools-extra/docs/clang-tidy/checks/misc-assert-side-effect.rst b/clang-tools-extra/docs/clang-tidy/checks/misc-assert-side-effect.rst index 3270d20daabe..3f8b4696793f 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/misc-assert-side-effect.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/misc-assert-side-effect.rst @@ -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 diff --git a/clang-tools-extra/docs/clang-tidy/checks/misc-dangling-handle.rst b/clang-tools-extra/docs/clang-tidy/checks/misc-dangling-handle.rst index 03c04e3b6046..03d03ed994a2 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/misc-dangling-handle.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/misc-dangling-handle.rst @@ -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. diff --git a/clang-tools-extra/docs/clang-tidy/checks/modernize-use-emplace.rst b/clang-tools-extra/docs/clang-tidy/checks/modernize-use-emplace.rst index 0f4d38d5a97e..fb35f282440b 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/modernize-use-emplace.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/modernize-use-emplace.rst @@ -13,12 +13,11 @@ because replacing ``insert`` with ``emplace`` may result in `speed regression `_, 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 v; v.push_back(MyClass(21, 37)); @@ -30,7 +29,7 @@ Before: After: -.. code:: c++ +.. code-block:: c++ std::vector v; v.emplace_back(21, 37); @@ -45,14 +44,14 @@ inside a container. Before: -.. code:: c++ +.. code-block:: c++ std::vector > v; v.push_back("abc"); After: -.. code:: c++ +.. code-block:: c++ std::vector > 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> v; v.push_back(std::unique_ptr(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(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.