]> granicus.if.org Git - clang/commitdiff
Add a DenseMapInfo specializaiton for CharUnits.
authorAnders Carlsson <andersca@mac.com>
Sun, 31 Oct 2010 21:17:03 +0000 (21:17 +0000)
committerAnders Carlsson <andersca@mac.com>
Sun, 31 Oct 2010 21:17:03 +0000 (21:17 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117872 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/CharUnits.h

index 0bb4b769d0f3517ba05c17e1781b7a2041c558a7..78f796dc9fde38397fd9fa8d56f296e5b2ce1f85 100644 (file)
@@ -14,6 +14,7 @@
 #ifndef LLVM_CLANG_AST_CHARUNITS_H
 #define LLVM_CLANG_AST_CHARUNITS_H
 
+#include "llvm/ADT/DenseMapInfo.h"
 #include "llvm/System/DataTypes.h"
 
 namespace clang {
@@ -146,4 +147,38 @@ inline clang::CharUnits operator* (clang::CharUnits::QuantityType Scale,
   return CU * Scale;
 }
 
+namespace llvm {
+
+template<> struct DenseMapInfo<clang::CharUnits> {
+  static clang::CharUnits getEmptyKey() {
+    clang::CharUnits::QuantityType Quantity =
+      DenseMapInfo<clang::CharUnits::QuantityType>::getEmptyKey();
+
+    return clang::CharUnits::fromQuantity(Quantity);
+  }
+
+  static clang::CharUnits getTombstoneKey() {
+    clang::CharUnits::QuantityType Quantity =
+      DenseMapInfo<clang::CharUnits::QuantityType>::getTombstoneKey();
+    
+    return clang::CharUnits::fromQuantity(Quantity);    
+  }
+
+  static unsigned getHashValue(const clang::CharUnits &CU) {
+    clang::CharUnits::QuantityType Quantity = CU.getQuantity();
+    return DenseMapInfo<clang::CharUnits::QuantityType>::getHashValue(Quantity);
+  }
+
+  static bool isEqual(const clang::CharUnits &LHS, 
+                      const clang::CharUnits &RHS) {
+    return LHS == RHS;
+  }
+};
+
+template <> struct isPodLike<clang::CharUnits> {
+  static const bool value = true;
+};
+  
+} // end namespace llvm
+
 #endif // LLVM_CLANG_AST_CHARUNITS_H