[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
This commit is contained in:
Roman Lebedev 2020-07-09 23:06:20 +03:00
parent caa423eef0
commit 29a9dd5bfe
No known key found for this signature in database
GPG Key ID: 083C3EBB4A1689E0
1 changed files with 3 additions and 0 deletions

View File

@ -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
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^