[llvm-commits] [llvm] r102768 - in /llvm/trunk: include/llvm/ADT/BitVector.h unittests/ADT/BitVectorTest.cpp unittests/ADT/SmallBitVectorTest.cpp
Dan Gohman
gohman at apple.com
Fri Apr 30 13:50:28 PDT 2010
Author: djg
Date: Fri Apr 30 15:50:28 2010
New Revision: 102768
URL: http://llvm.org/viewvc/llvm-project?rev=102768&view=rev
Log:
Update BitVectorTest.cpp to stay in sync with SmallBitVectorTest.cpp,
and fix a bug in BitVector's reference proxy class which this exposed.
Modified:
llvm/trunk/include/llvm/ADT/BitVector.h
llvm/trunk/unittests/ADT/BitVectorTest.cpp
llvm/trunk/unittests/ADT/SmallBitVectorTest.cpp
Modified: llvm/trunk/include/llvm/ADT/BitVector.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/BitVector.h?rev=102768&r1=102767&r2=102768&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/BitVector.h (original)
+++ llvm/trunk/include/llvm/ADT/BitVector.h Fri Apr 30 15:50:28 2010
@@ -49,6 +49,11 @@
~reference() {}
+ reference &operator=(reference t) {
+ *this = bool(t);
+ return *this;
+ }
+
reference& operator=(bool t) {
if (t)
*WordRef |= 1L << BitPos;
Modified: llvm/trunk/unittests/ADT/BitVectorTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/BitVectorTest.cpp?rev=102768&r1=102767&r2=102768&view=diff
==============================================================================
--- llvm/trunk/unittests/ADT/BitVectorTest.cpp (original)
+++ llvm/trunk/unittests/ADT/BitVectorTest.cpp Fri Apr 30 15:50:28 2010
@@ -7,7 +7,9 @@
//
//===----------------------------------------------------------------------===//
-#ifndef XFAIL
+// Some of these tests fail on PowerPC for unknown reasons.
+#ifndef __ppc__
+
#include "llvm/ADT/BitVector.h"
#include "gtest/gtest.h"
@@ -56,7 +58,7 @@
Vec.resize(26, true);
Vec.resize(29, false);
Vec.resize(33, true);
- Vec.resize(61, false);
+ Vec.resize(57, false);
unsigned Count = 0;
for (unsigned i = Vec.find_first(); i != -1u; i = Vec.find_next(i)) {
++Count;
@@ -67,7 +69,8 @@
EXPECT_EQ(Count, 23u);
EXPECT_FALSE(Vec[0]);
EXPECT_TRUE(Vec[32]);
- EXPECT_FALSE(Vec[60]);
+ EXPECT_FALSE(Vec[56]);
+ Vec.resize(61, false);
BitVector Copy = Vec;
BitVector Alt(3, false);
@@ -177,6 +180,15 @@
EXPECT_EQ(100U, A.size());
}
+TEST(BitVectorTest, ProxyIndex) {
+ BitVector Vec(3);
+ EXPECT_TRUE(Vec.none());
+ Vec[0] = Vec[1] = Vec[2] = true;
+ EXPECT_EQ(Vec.size(), Vec.count());
+ Vec[2] = Vec[1] = Vec[0] = false;
+ EXPECT_TRUE(Vec.none());
+}
+
}
#endif
Modified: llvm/trunk/unittests/ADT/SmallBitVectorTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/SmallBitVectorTest.cpp?rev=102768&r1=102767&r2=102768&view=diff
==============================================================================
--- llvm/trunk/unittests/ADT/SmallBitVectorTest.cpp (original)
+++ llvm/trunk/unittests/ADT/SmallBitVectorTest.cpp Fri Apr 30 15:50:28 2010
@@ -185,4 +185,5 @@
Vec[2] = Vec[1] = Vec[0] = false;
EXPECT_TRUE(Vec.none());
}
+
}
More information about the llvm-commits
mailing list