[clang-tools-extra] r299920 - Add more examples to clang tidy checkers

Sylvestre Ledru via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 11 00:10:48 PDT 2017


Author: sylvestre
Date: Tue Apr 11 02:10:48 2017
New Revision: 299920

URL: http://llvm.org/viewvc/llvm-project?rev=299920&view=rev
Log:
Add more examples to clang tidy checkers

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: cfe-commits

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D31860

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

Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/llvm-namespace-comment.rst
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/llvm-namespace-comment.rst?rev=299920&r1=299919&r2=299920&view=diff
==============================================================================
--- clang-tools-extra/trunk/docs/clang-tidy/checks/llvm-namespace-comment.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/llvm-namespace-comment.rst Tue Apr 11 02:10:48 2017
@@ -12,6 +12,19 @@ http://llvm.org/docs/CodingStandards.htm
 
 https://google.github.io/styleguide/cppguide.html#Namespaces
 
+.. code-block:: c++
+
+  namespace n1 {
+  void f();
+  }
+
+  // becomes
+
+  namespace n1 {
+  void f();
+  }  // namespace n1
+
+
 Options
 -------
 

Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/llvm-twine-local.rst
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/llvm-twine-local.rst?rev=299920&r1=299919&r2=299920&view=diff
==============================================================================
--- clang-tools-extra/trunk/docs/clang-tidy/checks/llvm-twine-local.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/llvm-twine-local.rst Tue Apr 11 02:10:48 2017
@@ -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();

Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/misc-inefficient-algorithm.rst
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/misc-inefficient-algorithm.rst?rev=299920&r1=299919&r2=299920&view=diff
==============================================================================
--- clang-tools-extra/trunk/docs/clang-tidy/checks/misc-inefficient-algorithm.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/misc-inefficient-algorithm.rst Tue Apr 11 02:10:48 2017
@@ -9,3 +9,21 @@ Warns on inefficient use of STL algorith
 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);

Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/misc-unused-parameters.rst
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/misc-unused-parameters.rst?rev=299920&r1=299919&r2=299920&view=diff
==============================================================================
--- clang-tools-extra/trunk/docs/clang-tidy/checks/misc-unused-parameters.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/misc-unused-parameters.rst Tue Apr 11 02:10:48 2017
@@ -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() {}

Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/performance-type-promotion-in-math-fn.rst
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/performance-type-promotion-in-math-fn.rst?rev=299920&r1=299919&r2=299920&view=diff
==============================================================================
--- clang-tools-extra/trunk/docs/clang-tidy/checks/performance-type-promotion-in-math-fn.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/performance-type-promotion-in-math-fn.rst Tue Apr 11 02:10:48 2017
@@ -9,3 +9,13 @@ with implicit ``float`` to ``double`` pr
 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);

Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-string-init.rst
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-string-init.rst?rev=299920&r1=299919&r2=299920&view=diff
==============================================================================
--- clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-string-init.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-string-init.rst Tue Apr 11 02:10:48 2017
@@ -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;

Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/readability-uniqueptr-delete-release.rst
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/readability-uniqueptr-delete-release.rst?rev=299920&r1=299919&r2=299920&view=diff
==============================================================================
--- clang-tools-extra/trunk/docs/clang-tidy/checks/readability-uniqueptr-delete-release.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/readability-uniqueptr-delete-release.rst Tue Apr 11 02:10:48 2017
@@ -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;




More information about the cfe-commits mailing list