summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/docs/clang-tidy
diff options
context:
space:
mode:
authorAngel Garcia Gomez <angelgarcia@google.com>2015-10-01 14:50:40 +0000
committerAngel Garcia Gomez <angelgarcia@google.com>2015-10-01 14:50:40 +0000
commit05ca3ec7d08129f5cd8d26f883ca91339b841c0b (patch)
treeec46cb7bc44c1d315caac007a071f43556fd5472 /clang-tools-extra/docs/clang-tidy
parent44f5d91af9eea0dbc33ffa285170a29ab44aa796 (diff)
downloadbcm5719-llvm-05ca3ec7d08129f5cd8d26f883ca91339b841c0b.tar.gz
bcm5719-llvm-05ca3ec7d08129f5cd8d26f883ca91339b841c0b.zip
Update clang-tidy documentation.
Summary: Improve modernize-use-auto documentation (https://llvm.org/bugs/show_bug.cgi?id=24962). Add documentation for modernize-make-unique. Reviewers: klimek Subscribers: cfe-commits, alexfh Differential Revision: http://reviews.llvm.org/D13346 llvm-svn: 249017
Diffstat (limited to 'clang-tools-extra/docs/clang-tidy')
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/list.rst1
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/modernize-make-unique.rst15
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/modernize-use-auto.rst33
3 files changed, 49 insertions, 0 deletions
diff --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst b/clang-tools-extra/docs/clang-tidy/checks/list.rst
index 1260a9deeed..497670e10b9 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -42,6 +42,7 @@ List of clang-tidy Checks
misc-unused-parameters
misc-unused-raii
modernize-loop-convert
+ modernize-make-unique
modernize-pass-by-value
modernize-replace-auto-ptr
modernize-shrink-to-fit
diff --git a/clang-tools-extra/docs/clang-tidy/checks/modernize-make-unique.rst b/clang-tools-extra/docs/clang-tidy/checks/modernize-make-unique.rst
new file mode 100644
index 00000000000..df9d5545cea
--- /dev/null
+++ b/clang-tools-extra/docs/clang-tidy/checks/modernize-make-unique.rst
@@ -0,0 +1,15 @@
+modernize-make-unique
+=====================
+
+This check finds the creation of ``std::unique_ptr`` objects by explicitly
+calling the constructor and a ``new`` expression, and replaces it with a call
+to ``std::make_unique``, introduced in C++14.
+
+.. code-block:: c++
+
+ auto my_ptr = std::unique_ptr<MyPair>(new MyPair(1, 2));
+
+ // becomes
+
+ auto my_ptr = std::make_unique<MyPair>(1, 2);
+
diff --git a/clang-tools-extra/docs/clang-tidy/checks/modernize-use-auto.rst b/clang-tools-extra/docs/clang-tidy/checks/modernize-use-auto.rst
index 39bc3854a4e..1a72657c4aa 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/modernize-use-auto.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/modernize-use-auto.rst
@@ -108,6 +108,39 @@ conditions are satisfied:
list. Otherwise, use of ``auto`` would cause the type of the variable to be
deduced as``std::initializer_list``.
+New expressions
+---------------
+
+Frequently, when a pointer is declared and initialized with ``new``, the
+pointee type has to be written twice: in the declaration type and in the
+``new`` expression. In this cases, the declaration type can be replaced with
+``auto`` improving readability and maintainability.
+
+.. code-block:: c++
+
+ TypeName *my_pointer = new TypeName(my_param);
+
+ // becomes
+
+ auto my_pointer = new TypeName(my_param);
+
+The check will also replace the declaration type in multiple declarations, if
+the following conditions are satisfied:
+
+* All declared variables have the same type (i.e. all of them are pointers to
+ the same type).
+* All declared variables are initialized with a ``new`` expression.
+* The types of all the new expressions are the same than the pointee of the
+ declaration type.
+
+.. code-block:: c++
+
+ TypeName *my_first_pointer = new TypeName, *my_second_pointer = new TypeName;
+
+ // becomes
+
+ auto my_first_pointer = new TypeName, my_second_pointer = new TypeName;
+
Known Limitations
-----------------
* If the initializer is an explicit conversion constructor, the check will not
OpenPOWER on IntegriCloud