[cfe-commits] r117872 - /cfe/trunk/include/clang/AST/CharUnits.h

Anders Carlsson andersca at mac.com
Sun Oct 31 14:17:03 PDT 2010


Author: andersca
Date: Sun Oct 31 16:17:03 2010
New Revision: 117872

URL: http://llvm.org/viewvc/llvm-project?rev=117872&view=rev
Log:
Add a DenseMapInfo specializaiton for CharUnits.

Modified:
    cfe/trunk/include/clang/AST/CharUnits.h

Modified: cfe/trunk/include/clang/AST/CharUnits.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CharUnits.h?rev=117872&r1=117871&r2=117872&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/CharUnits.h (original)
+++ cfe/trunk/include/clang/AST/CharUnits.h Sun Oct 31 16:17:03 2010
@@ -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 @@
   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





More information about the cfe-commits mailing list