[PATCH] D31860: Add more examples to clang tidy checkers

2017-04-13 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: docs/clang-tidy/checks/misc-unused-parameters.rst:15
+
+  void a(int  /*i*/) {}
+

sylvestre.ledru wrote:
> alexfh wrote:
> > nit: two spaces before the comment.
> I believe it is the case ? 
> I stole this from the unit test //test/clang-tidy/misc-unused-parameters.c//
Indeed. But now we have `-format-style=` option to fix formatting after 
applying fixes ;). Since it's not on by default, it's fair to leave the example 
as is.


https://reviews.llvm.org/D31860



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31860: Add more examples to clang tidy checkers

2017-04-11 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added inline comments.



Comment at: docs/clang-tidy/checks/misc-unused-parameters.rst:15
+
+  void a(int  /*i*/) {}
+

alexfh wrote:
> nit: two spaces before the comment.
I believe it is the case ? 
I stole this from the unit test //test/clang-tidy/misc-unused-parameters.c//



Comment at: docs/clang-tidy/checks/readability-uniqueptr-delete-release.rst:11
+
+  delete P.release();
+

alexfh wrote:
> nit: I'd add a bit more context, namely the definition of P.
done in r299961


https://reviews.llvm.org/D31860



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31860: Add more examples to clang tidy checkers

2017-04-11 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

Another couple of post-commit comments.




Comment at: docs/clang-tidy/checks/misc-unused-parameters.rst:15
+
+  void a(int  /*i*/) {}
+

nit: two spaces before the comment.



Comment at: docs/clang-tidy/checks/readability-uniqueptr-delete-release.rst:11
+
+  delete P.release();
+

nit: I'd add a bit more context, namely the definition of P.


https://reviews.llvm.org/D31860



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31860: Add more examples to clang tidy checkers

2017-04-10 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

Thanks!

LG with a couple of nits.




Comment at: docs/clang-tidy/checks/misc-inefficient-algorithm.rst:25
+  std::set s;
+  auto c = count(s.begin(), s.end(), 43);
+

std::count



Comment at: docs/clang-tidy/checks/misc-unused-parameters.rst:25
+
+  static void staticFunctionA()

The example seems incomplete?


https://reviews.llvm.org/D31860



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31860: Add more examples to clang tidy checkers

2017-04-10 Thread Sylvestre Ledru via Phabricator via cfe-commits
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 .release()`` with `` = 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 s;
+  auto it = std::find(s.begin(), s.end(), 43);
+
+  // becomes
+
+  auto it = s.find(43);
+
+.. code-block:: c++
+
+  std::set 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