summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/llvm-namespace-comment.rst13
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/llvm-twine-local.rst8
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/misc-inefficient-algorithm.rst18
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/misc-unused-parameters.rst19
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/performance-type-promotion-in-math-fn.rst10
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/readability-redundant-string-init.rst5
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/readability-uniqueptr-delete-release.rst8
7 files changed, 81 insertions, 0 deletions
diff --git a/clang-tools-extra/docs/clang-tidy/checks/llvm-namespace-comment.rst b/clang-tools-extra/docs/clang-tidy/checks/llvm-namespace-comment.rst
index 881b202f9bf..f6bc598505d 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/llvm-namespace-comment.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/llvm-namespace-comment.rst
@@ -12,6 +12,19 @@ http://llvm.org/docs/CodingStandards.html#namespace-indentation
https://google.github.io/styleguide/cppguide.html#Namespaces
+.. code-block:: c++
+
+ namespace n1 {
+ void f();
+ }
+
+ // becomes
+
+ namespace n1 {
+ void f();
+ } // namespace n1
+
+
Options
-------
diff --git a/clang-tools-extra/docs/clang-tidy/checks/llvm-twine-local.rst b/clang-tools-extra/docs/clang-tidy/checks/llvm-twine-local.rst
index 5ce0302b5d8..ec9ef1c6091 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/llvm-twine-local.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/llvm-twine-local.rst
@@ -6,3 +6,11 @@ llvm-twine-local
Looks for local ``Twine`` variables which are prone to use after frees and
should be generally avoided.
+
+.. code-block:: c++
+
+ static Twine Moo = Twine("bark") + "bah";
+
+ // becomes
+
+ static std::string Moo = (Twine("bark") + "bah").str();
diff --git a/clang-tools-extra/docs/clang-tidy/checks/misc-inefficient-algorithm.rst b/clang-tools-extra/docs/clang-tidy/checks/misc-inefficient-algorithm.rst
index c61db68e5a6..00324876c6f 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/misc-inefficient-algorithm.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/misc-inefficient-algorithm.rst
@@ -9,3 +9,21 @@ Warns on inefficient use of STL algorithms on associative containers.
Associative containers implements some of the algorithms as methods which
should be preferred to the algorithms in the algorithm header. The methods
can take advanatage of the order of the elements.
+
+.. code-block:: c++
+
+ std::set<int> s;
+ auto it = std::find(s.begin(), s.end(), 43);
+
+ // becomes
+
+ auto it = s.find(43);
+
+.. code-block:: c++
+
+ std::set<int> s;
+ auto c = std::count(s.begin(), s.end(), 43);
+
+ // becomes
+
+ auto c = s.count(43);
diff --git a/clang-tools-extra/docs/clang-tidy/checks/misc-unused-parameters.rst b/clang-tools-extra/docs/clang-tidy/checks/misc-unused-parameters.rst
index 4e037351b27..de868b91858 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/misc-unused-parameters.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/misc-unused-parameters.rst
@@ -5,3 +5,22 @@ misc-unused-parameters
Finds unused parameters and fixes them, so that `-Wunused-parameter` can be
turned on.
+
+.. code-block:: c++
+
+ void a(int i) {}
+
+ // becomes
+
+ void a(int /*i*/) {}
+
+
+.. code-block:: c++
+
+ static void staticFunctionA(int i);
+ static void staticFunctionA(int i) {}
+
+ // becomes
+
+ static void staticFunctionA()
+ static void staticFunctionA() {}
diff --git a/clang-tools-extra/docs/clang-tidy/checks/performance-type-promotion-in-math-fn.rst b/clang-tools-extra/docs/clang-tidy/checks/performance-type-promotion-in-math-fn.rst
index fcd03751425..a27a48294ef 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/performance-type-promotion-in-math-fn.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/performance-type-promotion-in-math-fn.rst
@@ -9,3 +9,13 @@ with implicit ``float`` to ``double`` promotions.
For example, warns on ``::sin(0.f)``, because this funciton's parameter is a
double. You probably meant to call ``std::sin(0.f)`` (in C++), or ``sinf(0.f)``
(in C).
+
+.. code-block:: c++
+
+ float a;
+ asin(a);
+
+ // becomes
+
+ float a;
+ std::asin(a);
diff --git a/clang-tools-extra/docs/clang-tidy/checks/readability-redundant-string-init.rst b/clang-tools-extra/docs/clang-tidy/checks/readability-redundant-string-init.rst
index a5530a9a8f3..e4136ea4234 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/readability-redundant-string-init.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/readability-redundant-string-init.rst
@@ -12,3 +12,8 @@ Examples:
// Initializing string with empty string literal is unnecessary.
std::string a = "";
std::string b("");
+
+ // becomes
+
+ std::string a;
+ std::string b;
diff --git a/clang-tools-extra/docs/clang-tidy/checks/readability-uniqueptr-delete-release.rst b/clang-tools-extra/docs/clang-tidy/checks/readability-uniqueptr-delete-release.rst
index 83122356d46..54a70625a4e 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/readability-uniqueptr-delete-release.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/readability-uniqueptr-delete-release.rst
@@ -5,3 +5,11 @@ readability-uniqueptr-delete-release
Replace ``delete <unique_ptr>.release()`` with ``<unique_ptr> = nullptr``.
The latter is shorter, simpler and does not require use of raw pointer APIs.
+
+.. code-block:: c++
+
+ delete P.release();
+
+ // becomes
+
+ P = nullptr;
OpenPOWER on IntegriCloud