[PATCH] D32060: BitVector: add iterators for bits that are set

Francis Visoiu Mistrih via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 13 15:51:19 PDT 2017


thegameg created this revision.

Add iterators to iterate on the bits of the bit vector that are set. This is useful when BitVector is used as a `set<unsigned>`, which usually is a set of basic block numbers or a set of registers.

D30808 <https://reviews.llvm.org/D30808> would be a user of this.

This would allow us to transform:

  for (int Elt = Vector.find_first(); Elt >= 0; Elt = Vector.find_next(Elt)) {
    // Stuff
  }

into

  for (int Elt : Vector.bits_set()) {
    // Stuff
  }


https://reviews.llvm.org/D32060

Files:
  include/llvm/ADT/BitVector.h
  include/llvm/ADT/SmallBitVector.h
  unittests/ADT/BitVectorTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32060.95232.patch
Type: text/x-patch
Size: 4356 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170413/2e830ee4/attachment.bin>


More information about the llvm-commits mailing list