Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm/include/llvm/ADT/BitVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ class BitVector {
}
bool isInvalid() const { return Size == (unsigned)-1; }

ArrayRef<BitWord> getData() const { return {&Bits[0], Bits.size()}; }
ArrayRef<BitWord> getData() const { return {Bits.data(), Bits.size()}; }

//===--------------------------------------------------------------------===//
// Portable bit mask operations.
Expand Down
8 changes: 8 additions & 0 deletions llvm/unittests/ADT/BitVectorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1134,6 +1134,14 @@ TYPED_TEST(BitVectorTest, EmptyVector) {
testEmpty(E);
}

/// Make sure calling getData() is legal even on an empty BitVector
TYPED_TEST(BitVectorTest, EmptyVectorGetData) {
BitVector A;
testEmpty(A);
auto B = A.getData();
EXPECT_TRUE(B.empty());
}

TYPED_TEST(BitVectorTest, Iterators) {
TypeParam Filled(10, true);
EXPECT_NE(Filled.set_bits_begin(), Filled.set_bits_end());
Expand Down