aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2010-10-31 21:17:03 +0000
committerAnders Carlsson <andersca@mac.com>2010-10-31 21:17:03 +0000
commit94ac122610ec875760c4b41e7376b79223a0de20 (patch)
treed6d8e3d229ad854829ea7e336e6bb7924d17e3f5
parent7e7492442f32e3abbe246f6bb35568b044c1188b (diff)
Add a DenseMapInfo specializaiton for CharUnits.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117872 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/CharUnits.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/include/clang/AST/CharUnits.h b/include/clang/AST/CharUnits.h
index 0bb4b769d0..78f796dc9f 100644
--- a/include/clang/AST/CharUnits.h
+++ b/include/clang/AST/CharUnits.h
@@ -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