summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.h14
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/list.rst4
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/modernize-replace-auto-ptr.rst29
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/modernize-use-auto.rst4
4 files changed, 44 insertions, 7 deletions
diff --git a/clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.h b/clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.h
index 4aad852c8b0..f8cc034b53a 100644
--- a/clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.h
+++ b/clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.h
@@ -17,24 +17,26 @@ namespace clang {
namespace tidy {
namespace modernize {
-/// \brief Transforms the deprecated \c std::auto_ptr into the C++11 \c
-/// std::unique_ptr.
+/// Transforms the deprecated `std::auto_ptr` into the C++11 `std::unique_ptr`.
///
-/// Note that both the \c std::auto_ptr type and the transfer of ownership are
-/// transformed. \c std::auto_ptr provides two ways to transfer the ownership,
+/// Note that both the `std::auto_ptr` type and the transfer of ownership are
+/// transformed. `std::auto_ptr` provides two ways to transfer the ownership,
/// the copy-constructor and the assignment operator. Unlike most classes these
/// operations do not 'copy' the resource but they 'steal' it.
-/// \c std::unique_ptr uses move semantics instead, which makes the intent of
+/// `std::unique_ptr` uses move semantics instead, which makes the intent of
/// transferring the resource explicit. This difference between the two smart
/// pointers requeres to wrap the copy-ctor and assign-operator with
-/// \c std::move().
+/// `std::move()`.
///
/// For example, given:
+///
/// \code
/// std::auto_ptr<int> i, j;
/// i = j;
/// \endcode
+///
/// This code is transformed to:
+///
/// \code
/// std::unique_ptr<in> i, j;
/// i = std::move(j);
diff --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst b/clang-tools-extra/docs/clang-tidy/checks/list.rst
index 05aebe8d298..abd5b8ef395 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -40,7 +40,9 @@ List of clang-tidy Checks
misc-unused-raii
modernize-loop-convert
modernize-pass-by-value
+ modernize-replace-auto-ptr
modernize-shrink-to-fit
+ modernize-use-auto
modernize-use-nullptr
modernize-use-override
readability-braces-around-statements
@@ -51,4 +53,4 @@ List of clang-tidy Checks
readability-named-parameter
readability-redundant-smartptr-get
readability-redundant-string-cstr
- readability-simplify-boolean-expr
+ readability-simplify-boolean-expr \ No newline at end of file
diff --git a/clang-tools-extra/docs/clang-tidy/checks/modernize-replace-auto-ptr.rst b/clang-tools-extra/docs/clang-tidy/checks/modernize-replace-auto-ptr.rst
new file mode 100644
index 00000000000..09290f19e78
--- /dev/null
+++ b/clang-tools-extra/docs/clang-tidy/checks/modernize-replace-auto-ptr.rst
@@ -0,0 +1,29 @@
+modernize-replace-auto-ptr
+==========================
+
+
+Transforms the deprecated ``std::auto_ptr`` into the C++11 ``std::unique_ptr``.
+
+Note that both the ``std::auto_ptr`` type and the transfer of ownership are
+transformed. ``std::auto_ptr`` provides two ways to transfer the ownership,
+the copy-constructor and the assignment operator. Unlike most classes these
+operations do not 'copy' the resource but they 'steal' it.
+``std::unique_ptr`` uses move semantics instead, which makes the intent of
+transferring the resource explicit. This difference between the two smart
+pointers requeres to wrap the copy-ctor and assign-operator with
+``std::move()``.
+
+For example, given:
+
+.. code:: c++
+
+ std::auto_ptr<int> i, j;
+ i = j;
+
+This code is transformed to:
+
+.. code:: c++
+
+ std::unique_ptr<in> i, j;
+ i = std::move(j);
+
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
new file mode 100644
index 00000000000..db2b20a7aca
--- /dev/null
+++ b/clang-tools-extra/docs/clang-tidy/checks/modernize-use-auto.rst
@@ -0,0 +1,4 @@
+modernize-use-auto
+==================
+
+
OpenPOWER on IntegriCloud