diff --git a/include/llvm/ADT/SmallPtrSet.h b/include/llvm/ADT/SmallPtrSet.h index b52aebf7d55..e433c57de74 100644 --- a/include/llvm/ADT/SmallPtrSet.h +++ b/include/llvm/ADT/SmallPtrSet.h @@ -271,9 +271,9 @@ public: return erase_imp(PtrTraits::getAsVoidPointer(Ptr)); } - /// count - Return true if the specified pointer is in the set. - bool count(PtrType Ptr) const { - return count_imp(PtrTraits::getAsVoidPointer(Ptr)); + /// count - Return 1 if the specified pointer is in the set, 0 otherwise. + unsigned count(PtrType Ptr) const { + return count_imp(PtrTraits::getAsVoidPointer(Ptr)) ? 1 : 0; } template diff --git a/include/llvm/ADT/SmallSet.h b/include/llvm/ADT/SmallSet.h index ecd3843cd0a..6f36234cb4d 100644 --- a/include/llvm/ADT/SmallSet.h +++ b/include/llvm/ADT/SmallSet.h @@ -47,11 +47,11 @@ public: return isSmall() ? Vector.size() : Set.size(); } - /// count - Return true if the element is in the set. - bool count(const T &V) const { + /// count - Return 1 if the element is in the set, 0 otherwise. + unsigned count(const T &V) const { if (isSmall()) { // Since the collection is small, just do a linear search. - return vfind(V) != Vector.end(); + return vfind(V) == Vector.end() ? 0 : 1; } else { return Set.count(V); } diff --git a/include/llvm/ADT/SparseSet.h b/include/llvm/ADT/SparseSet.h index 267a340a758..ded48c5746a 100644 --- a/include/llvm/ADT/SparseSet.h +++ b/include/llvm/ADT/SparseSet.h @@ -227,10 +227,11 @@ public: return const_cast(this)->findIndex(KeyIndexOf(Key)); } - /// count - Returns true if this set contains an element identified by Key. + /// count - Returns 1 if this set contains an element identified by Key, + /// 0 otherwise. /// - bool count(const KeyT &Key) const { - return find(Key) != end(); + unsigned count(const KeyT &Key) const { + return find(Key) == end() ? 0 : 1; } /// insert - Attempts to insert a new element. diff --git a/include/llvm/ADT/StringMap.h b/include/llvm/ADT/StringMap.h index 0838ebe91f1..f22ce80df72 100644 --- a/include/llvm/ADT/StringMap.h +++ b/include/llvm/ADT/StringMap.h @@ -313,6 +313,7 @@ public: return GetOrCreateValue(Key).getValue(); } + /// count - Return 1 if the element is in the map, 0 otherwise. size_type count(StringRef Key) const { return find(Key) == end() ? 0 : 1; }