sylvestre.ledru created this revision.
sylvestre.ledru added a project: clang-tools-extra.

https://reviews.llvm.org/D31860

Files:
  docs/clang-tidy/checks/llvm-namespace-comment.rst
  docs/clang-tidy/checks/llvm-twine-local.rst
  docs/clang-tidy/checks/misc-inefficient-algorithm.rst
  docs/clang-tidy/checks/misc-unused-parameters.rst
  docs/clang-tidy/checks/performance-type-promotion-in-math-fn.rst
  docs/clang-tidy/checks/readability-redundant-string-init.rst
  docs/clang-tidy/checks/readability-uniqueptr-delete-release.rst

Index: docs/clang-tidy/checks/readability-uniqueptr-delete-release.rst
===================================================================
--- docs/clang-tidy/checks/readability-uniqueptr-delete-release.rst
+++ docs/clang-tidy/checks/readability-uniqueptr-delete-release.rst
@@ -5,3 +5,11 @@
 
 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;
Index: docs/clang-tidy/checks/readability-redundant-string-init.rst
===================================================================
--- docs/clang-tidy/checks/readability-redundant-string-init.rst
+++ docs/clang-tidy/checks/readability-redundant-string-init.rst
@@ -12,3 +12,8 @@
   // Initializing string with empty string literal is unnecessary.
   std::string a = "";
   std::string b("");
+
+  // becomes
+
+  std::string a;
+  std::string b;
Index: docs/clang-tidy/checks/performance-type-promotion-in-math-fn.rst
===================================================================
--- docs/clang-tidy/checks/performance-type-promotion-in-math-fn.rst
+++ docs/clang-tidy/checks/performance-type-promotion-in-math-fn.rst
@@ -9,3 +9,13 @@
 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);
Index: docs/clang-tidy/checks/misc-unused-parameters.rst
===================================================================
--- docs/clang-tidy/checks/misc-unused-parameters.rst
+++ docs/clang-tidy/checks/misc-unused-parameters.rst
@@ -5,3 +5,21 @@
 
 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()
Index: docs/clang-tidy/checks/misc-inefficient-algorithm.rst
===================================================================
--- docs/clang-tidy/checks/misc-inefficient-algorithm.rst
+++ docs/clang-tidy/checks/misc-inefficient-algorithm.rst
@@ -9,3 +9,21 @@
 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 = count(s.begin(), s.end(), 43);
+
+  // becomes
+
+  auto c = s.count(43);
Index: docs/clang-tidy/checks/llvm-twine-local.rst
===================================================================
--- docs/clang-tidy/checks/llvm-twine-local.rst
+++ docs/clang-tidy/checks/llvm-twine-local.rst
@@ -6,3 +6,11 @@
 
 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();
Index: docs/clang-tidy/checks/llvm-namespace-comment.rst
===================================================================
--- docs/clang-tidy/checks/llvm-namespace-comment.rst
+++ docs/clang-tidy/checks/llvm-namespace-comment.rst
@@ -12,6 +12,19 @@
 
 https://google.github.io/styleguide/cppguide.html#Namespaces
 
+.. code-block:: c++
+
+  namespace n1 {
+  void f();
+  }
+
+  // becomes
+
+  namespace n1 {
+  void f();
+  }  // namespace n1
+
+
 Options
 -------
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to