[llvm] 29a9dd5 - [Docs] CodingStandards: for_each is discouraged

Roman Lebedev via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 9 13:11:13 PDT 2020


Author: Roman Lebedev
Date: 2020-07-09T23:10:42+03:00
New Revision: 29a9dd5bfe50be9b6aecbe95c6670734e5ee29c5

URL: https://github.com/llvm/llvm-project/commit/29a9dd5bfe50be9b6aecbe95c6670734e5ee29c5
DIFF: https://github.com/llvm/llvm-project/commit/29a9dd5bfe50be9b6aecbe95c6670734e5ee29c5.diff

LOG: [Docs] CodingStandards: for_each is discouraged

Summary:
As per disscussion in D83351, using `for_each` is potentially confusing,
at least in regards to inconsistent style (there's less than 100 `for_each`
usages in LLVM, but ~100.000 `for` range-based loops

Therefore, it should be avoided.

Reviewers: dblaikie, nickdesaulniers

Reviewed By: dblaikie, nickdesaulniers

Subscribers: hubert.reinterpretcast, llvm-commits

Tags: #llvm

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

Added: 
    

Modified: 
    llvm/docs/CodingStandards.rst

Removed: 
    


################################################################################
diff  --git a/llvm/docs/CodingStandards.rst b/llvm/docs/CodingStandards.rst
index 861ab05420fb..99fb6af02a28 100644
--- a/llvm/docs/CodingStandards.rst
+++ b/llvm/docs/CodingStandards.rst
@@ -1302,6 +1302,9 @@ loops wherever possible for all newly added code. For example:
   for (Instruction &I : *BB)
     ... use I ...
 
+Usage of ``std::for_each()``/``llvm::for_each()`` functions is discouraged,
+unless the the callable object already exists.
+
 Don't evaluate ``end()`` every time through a loop
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 


        


More information about the llvm-commits mailing list