X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FADT%2FValueMap.h;h=d23fccf3e8cc1f18f8dc31f447c42288b6ee24c6;hb=658c62862e470b59aaf25825de64d93fbaf8cb93;hp=af041fe5216f8137e385fb1dcfece497ce5d0321;hpb=fffe6cf084d91a8c99b710e30f2b9fb23d62b58d;p=oota-llvm.git diff --git a/include/llvm/ADT/ValueMap.h b/include/llvm/ADT/ValueMap.h index af041fe5216..d23fccf3e8c 100644 --- a/include/llvm/ADT/ValueMap.h +++ b/include/llvm/ADT/ValueMap.h @@ -29,13 +29,13 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/Support/ValueHandle.h" #include "llvm/Support/type_traits.h" -#include "llvm/System/Mutex.h" +#include "llvm/Support/Mutex.h" #include namespace llvm { -template +template class ValueMapCallbackVH; template @@ -72,18 +72,16 @@ struct ValueMapConfig { }; /// See the file comment. -template, - typename ValueInfoT = DenseMapInfo > +template > class ValueMap { - friend class ValueMapCallbackVH; - typedef ValueMapCallbackVH ValueMapCVH; - typedef DenseMap, - ValueInfoT> MapT; + friend class ValueMapCallbackVH; + typedef ValueMapCallbackVH ValueMapCVH; + typedef DenseMap > MapT; typedef typename Config::ExtraData ExtraData; MapT Map; ExtraData Data; - ValueMap(const ValueMap&); // DO NOT IMPLEMENT - ValueMap& operator=(const ValueMap&); // DO NOT IMPLEMENT + ValueMap(const ValueMap&) LLVM_DELETED_FUNCTION; + ValueMap& operator=(const ValueMap&) LLVM_DELETED_FUNCTION; public: typedef KeyT key_type; typedef ValueT mapped_type; @@ -113,20 +111,21 @@ public: /// count - Return true if the specified key is in the map. bool count(const KeyT &Val) const { - return Map.count(Wrap(Val)); + return Map.find_as(Val) != Map.end(); } iterator find(const KeyT &Val) { - return iterator(Map.find(Wrap(Val))); + return iterator(Map.find_as(Val)); } const_iterator find(const KeyT &Val) const { - return const_iterator(Map.find(Wrap(Val))); + return const_iterator(Map.find_as(Val)); } /// lookup - Return the entry for the specified key, or a default /// constructed value if no such entry exists. ValueT lookup(const KeyT &Val) const { - return Map.lookup(Wrap(Val)); + typename MapT::const_iterator I = Map.find_as(Val); + return I != Map.end() ? I->second : ValueT(); } // Inserts key,value pair into the map if the key isn't already in the map. @@ -147,9 +146,14 @@ public: bool erase(const KeyT &Val) { - return Map.erase(Wrap(Val)); + typename MapT::iterator I = Map.find_as(Val); + if (I == Map.end()) + return false; + + Map.erase(I); + return true; } - bool erase(iterator I) { + void erase(iterator I) { return Map.erase(I.base()); } @@ -190,11 +194,11 @@ private: // This CallbackVH updates its ValueMap when the contained Value changes, // according to the user's preferences expressed through the Config object. -template +template class ValueMapCallbackVH : public CallbackVH { - friend class ValueMap; + friend class ValueMap; friend struct DenseMapInfo; - typedef ValueMap ValueMapT; + typedef ValueMap ValueMapT; typedef typename llvm::remove_pointer::type KeySansPointerT; ValueMapT *Map; @@ -244,9 +248,9 @@ public: } }; -template -struct DenseMapInfo > { - typedef ValueMapCallbackVH VH; +template +struct DenseMapInfo > { + typedef ValueMapCallbackVH VH; typedef DenseMapInfo PointerInfo; static inline VH getEmptyKey() { @@ -258,9 +262,15 @@ struct DenseMapInfo > { static unsigned getHashValue(const VH &Val) { return PointerInfo::getHashValue(Val.Unwrap()); } + static unsigned getHashValue(const KeyT &Val) { + return PointerInfo::getHashValue(Val); + } static bool isEqual(const VH &LHS, const VH &RHS) { return LHS == RHS; } + static bool isEqual(const KeyT &LHS, const VH &RHS) { + return LHS == RHS.getValPtr(); + } };