Add BitVector::anyCommon().
[oota-llvm.git] / include / llvm / ADT / BitVector.h
index 7e0b5ba371969366659df89b8936d0ce3dc0099e..bf6d76fbcc3194ec54b5998a4d22e81d4ce5fc31 100644 (file)
@@ -272,6 +272,16 @@ public:
     return (*this)[Idx];
   }
 
+  /// Test if any common bits are set.
+  bool anyCommon(const BitVector &RHS) const {
+    unsigned ThisWords = NumBitWords(size());
+    unsigned RHSWords  = NumBitWords(RHS.size());
+    for (unsigned i = 0, e = std::min(ThisWords, RHSWords); i != e; ++i)
+      if (Bits[i] & RHS.Bits[i])
+        return true;
+    return false;
+  }
+
   // Comparison operators.
   bool operator==(const BitVector &RHS) const {
     unsigned ThisWords = NumBitWords(size());