IR/Attributes: Provide EmptyKey and TombstoneKey in part of enum, as workaround for...
authorNAKAMURA Takumi <geek4civic@gmail.com>
Sat, 5 Jan 2013 07:55:47 +0000 (07:55 +0000)
committerNAKAMURA Takumi <geek4civic@gmail.com>
Sat, 5 Jan 2013 07:55:47 +0000 (07:55 +0000)
I will investigate, later, what was wrong. I am too tired for now.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171611 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/IR/Attributes.h
lib/IR/Attributes.cpp

index 28ec9db62e7888656755e82376c8edbddb60bf46..1932ffd3cb7aa0ed4a6c7cc25bd68135943628ca 100644 (file)
@@ -93,7 +93,11 @@ public:
     UWTable,               ///< Function must be in a unwind table
     ZExt,                  ///< Zero extended before/after call
 
-    EndAttrKinds           ///< Sentinal value useful for loops
+    EndAttrKinds,          ///< Sentinal value useful for loops
+
+    // Values for DenseMapInfo
+    EmptyKey     = 0x7FFFFFFF,
+    TombstoneKey = -0x7FFFFFFF - 1
   };
 private:
   AttributeImpl *pImpl;
@@ -165,10 +169,10 @@ public:
 /// AttrBuilder.
 template<> struct DenseMapInfo<Attribute::AttrKind> {
   static inline Attribute::AttrKind getEmptyKey() {
-    return Attribute::AttrKind(~0U);
+    return Attribute::EmptyKey;
   }
   static inline Attribute::AttrKind getTombstoneKey() {
-    return Attribute::AttrKind(~0U - 1);
+    return Attribute::TombstoneKey;
   }
   static unsigned getHashValue(const Attribute::AttrKind &Val) {
     return Val * 37U;
index 84f90ade8b2aae92326569c1ddf761f7a3cd0732..039e036e894eb6e65dcfccf6dec643794ad7a08f 100644 (file)
@@ -426,6 +426,8 @@ uint64_t AttributeImpl::getBitMask() const {
 uint64_t AttributeImpl::getAttrMask(Attribute::AttrKind Val) {
   switch (Val) {
   case Attribute::EndAttrKinds:    break;
+  case Attribute::EmptyKey:        break;
+  case Attribute::TombstoneKey:    break;
   case Attribute::None:            return 0;
   case Attribute::ZExt:            return 1 << 0;
   case Attribute::SExt:            return 1 << 1;