[PATCH] D32682: Refactoring with range-based for, NFC

Wei-Ren Chen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 2 05:21:31 PDT 2017


chenwj added a comment.

In https://reviews.llvm.org/D32682#742714, @spatel wrote:

> IMO, this is going beyond LLVM's normal 'auto' usage prefs:
>  http://llvm.org/docs/CodingStandards.html#use-auto-type-deduction-to-make-code-more-readable
>
> If you can convert it to a range-loop, then you should specify the range element type including 'const' where appropriate. So something like this:
>
>   for (const SDValue &Op : NI->op_values())
>   
>
> Some of the diffs use regular loops and only replace the iterator type with an 'auto'. That should be a separate NFC patch. But it's not clear to me if that also goes too far into 'auto'.


By beyond, you mean those originally were `const_iterator` or all of them? FWIK, to make `auto` as `const_iterator`, we need the container provides `cbegin()/cend()`.
Or you know other way to make it happen?

Thanks.


https://reviews.llvm.org/D32682





More information about the llvm-commits mailing list