The count() function for STL datatypes returns unsigned, even where it's
only 1/0 result like std::set. Some of the LLVM ADT already return unsigned
count(), while others still return bool count().

In continuation to r197879, this patch modifies DenseMap, DenseSet,
ScopedHashTable, ValueMap:: count() to return unsigned instead of bool, 1
instead of true and 0 instead of false.

Yaron
Index: DenseMap.h
===================================================================
--- DenseMap.h  (revision 197903)
+++ DenseMap.h  (working copy)
@@ -99,10 +99,10 @@
     setNumTombstones(0);
   }
 
-  /// count - Return true if the specified key is in the map.
-  bool count(const KeyT &Val) const {
+  /// count - Return 1 if the specified key is in the map, 0 otherwise.
+  unsigned count(const KeyT &Val) const {
     const BucketT *TheBucket;
-    return LookupBucketFor(Val, TheBucket);
+    return LookupBucketFor(Val, TheBucket) ? 1 : 0;
   }
 
   iterator find(const KeyT &Val) {
Index: DenseSet.h
===================================================================
--- DenseSet.h  (revision 197903)
+++ DenseSet.h  (working copy)
@@ -42,7 +42,8 @@
     TheMap.clear();
   }
 
-  bool count(const ValueT &V) const {
+  /// count - Return 1 if the specified key is in the set, 0 otherwise.
+  unsigned count(const ValueT &V) const {
     return TheMap.count(V);
   }
 
Index: ScopedHashTable.h
===================================================================
--- ScopedHashTable.h   (revision 197903)
+++ ScopedHashTable.h   (working copy)
@@ -172,7 +172,7 @@
   AllocatorRefTy getAllocator() { return Allocator; }
   AllocatorCRefTy getAllocator() const { return Allocator; }
 
-  bool count(const K &Key) const {
+  unsigned count(const K &Key) const {
     return TopLevelMap.count(Key);
   }
 
Index: ValueMap.h
===================================================================
--- ValueMap.h  (revision 197903)
+++ ValueMap.h  (working copy)
@@ -108,9 +108,9 @@
 
   void clear() { Map.clear(); }
 
-  /// count - Return true if the specified key is in the map.
-  bool count(const KeyT &Val) const {
-    return Map.find_as(Val) != Map.end();
+  /// count - Return 1 if the specified key is in the map, 0 otherwise.
+  unsigned count(const KeyT &Val) const {
+    return Map.find_as(Val) == Map.end() ? 0 : 1;
   }
 
   iterator find(const KeyT &Val) {
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to