[PATCH] D103900: [llvm] Add enum iteration to Sequence
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 5 07:23:28 PDT 2021
lebedev.ri added inline comments.
================
Comment at: llvm/tools/llvm-reduce/deltas/ReduceAttributes.cpp:87-91
+ // `index_begin` is unsigned(~0), so effectively iterating ~0, 0, 1, 2...
+ // This is why we need to use `SetIdx != EndIdx` instead of `SetIdx <
+ // EndIdx`.
+ for (unsigned SetIdx = AL.index_begin(), EndIdx = AL.index_end();
+ SetIdx != EndIdx; ++SetIdx) {
----------------
Quuxplusone wrote:
> LGTM, but per @lebedev.ri 's comment in D83351, I think this would benefit from a follow-up patch that turns `index_begin` and `index_end` into `signed int`s.
> Style nit: Personally I'd rather see "`unsigned(-1)`" and "`-1, 0, 1...`", than "`unsigned(~0)`" and "`~0, 0, 1...`".
This change NACK.
It should probably be something like
```
for (unsigned SetIdx : seq<int>(AL.index_begin(), AL.index_end())) {
```
or
```
for (unsigned SetIdx : seq((int)AL.index_begin(), (int)AL.index_end())) {
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D103900/new/
https://reviews.llvm.org/D103900
More information about the llvm-commits
mailing list