summaryrefslogtreecommitdiff
path: root/include/llvm/IR/ValueMap.h
diff options
context:
space:
mode:
authorYaron Keren <yaron.keren@gmail.com>2014-06-20 10:26:56 +0000
committerYaron Keren <yaron.keren@gmail.com>2014-06-20 10:26:56 +0000
commited4e8a839f0604b51eb03f47b6cd467917162e89 (patch)
tree368959549ffb289cf6d428aeb506c73d1e8d0e6b /include/llvm/IR/ValueMap.h
parente5241cc48858af7c6ca58ae677b69323e8f84eb5 (diff)
downloadllvm-ed4e8a839f0604b51eb03f47b6cd467917162e89.tar.gz
llvm-ed4e8a839f0604b51eb03f47b6cd467917162e89.tar.bz2
llvm-ed4e8a839f0604b51eb03f47b6cd467917162e89.tar.xz
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 size_type instead of bool, 1 instead of true and 0 instead of false. size_type is typedef-ed locally within each class to size_t. http://reviews.llvm.org/D4018 Reviewed by dblaikie. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211350 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/IR/ValueMap.h')
-rw-r--r--include/llvm/IR/ValueMap.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/include/llvm/IR/ValueMap.h b/include/llvm/IR/ValueMap.h
index 17b0fe01b1..e459e4904c 100644
--- a/include/llvm/IR/ValueMap.h
+++ b/include/llvm/IR/ValueMap.h
@@ -87,6 +87,7 @@ public:
typedef KeyT key_type;
typedef ValueT mapped_type;
typedef std::pair<KeyT, ValueT> value_type;
+ typedef size_t size_type;
explicit ValueMap(unsigned NumInitBuckets = 64)
: Map(NumInitBuckets), Data() {}
@@ -103,16 +104,16 @@ public:
inline const_iterator end() const { return const_iterator(Map.end()); }
bool empty() const { return Map.empty(); }
- unsigned size() const { return Map.size(); }
+ size_type size() const { return Map.size(); }
/// Grow the map so that it has at least Size buckets. Does not shrink
void resize(size_t Size) { Map.resize(Size); }
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();
+ /// Return 1 if the specified key is in the map, 0 otherwise.
+ size_type count(const KeyT &Val) const {
+ return Map.find_as(Val) == Map.end() ? 0 : 1;
}
iterator find(const KeyT &Val) {