[PATCH] D18442: A clang-tidy check for std:accumulate.

Alexander Kornienko via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 25 07:50:40 PDT 2016


alexfh added a comment.

A few nits.


================
Comment at: clang-tidy/misc/FoldInitTypeCheck.cpp:90
@@ +89,3 @@
+  // It's OK to fold an int into:
+  //  - an int of the same size and signedness.
+  //  - a bigger int, regardless of signedness.
----------------
No, I don't have a better name. The fp reference fixes my confusion ;) Maybe add this link to the user-facing documentation to tune the readers on the right frequency?

================
Comment at: docs/clang-tidy/checks/misc-fold-init-type.rst:8
@@ +7,3 @@
+result in loss of precision.
+`std::accumulate` folds an input range into a initial value using the type of
+the latter, with `operator+` by default. This can cause loss of precision
----------------
s/a initial value/an initial value/

================
Comment at: docs/clang-tidy/checks/misc-fold-init-type.rst:16-17
@@ +15,4 @@
+
+.. code:: c++
+  auto a = {0.5f, 0.5f, 0.5f, 0.5f};
+  return std::accumulate(std::begin(a), std::end(a), 0);
----------------
Prazek wrote:
> Doesn't .. code node need new line?
Yes, it needs a new-line. Also, please verify the documentation actually builds with sphinx. On Ubuntu it should boil down to these commands:

  $ sudo apt-get install python-sphinx
  $ mkdir -p /some/build/directory && cd /some/build/directory
  $ cmake /path/to/llvm/ -DLLVM_ENABLE_SPHINX=ON
  $ make docs-clang-tools-html



http://reviews.llvm.org/D18442





More information about the cfe-commits mailing list