[PATCH] D37264: [Docs] Update CodingStandards to recommend range-based for loops
Aaron Ballman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 29 09:56:11 PDT 2017
aaron.ballman added inline comments.
================
Comment at: docs/CodingStandards.rst:944
- for (BasicBlock::iterator II = BB->begin(), E = BB->end(); II != E; ++II) {
- if (BinaryOperator *BO = dyn_cast<BinaryOperator>(II)) {
+ for (auto &I : BB) {
+ if (auto *BO = dyn_cast<BinaryOperator>(&I)) {
----------------
majnemer wrote:
> I'd replace the `auto` with `Instruction &`.
We should clarify this in the coding standard, because I've always understood we generally *want* to use `auto` in range-based for loops, for brevity (and because the type is generally immediately apparent from the container).
https://reviews.llvm.org/D37264
More information about the llvm-commits
mailing list