From: Anders Carlsson Date: Sun, 31 Oct 2010 21:17:03 +0000 (+0000) Subject: Add a DenseMapInfo specializaiton for CharUnits. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=94ac122610ec875760c4b41e7376b79223a0de20;p=clang Add a DenseMapInfo specializaiton for CharUnits. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117872 91177308-0d34-0410-b5e6-96231b3b80d8 --- 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 { + static clang::CharUnits getEmptyKey() { + clang::CharUnits::QuantityType Quantity = + DenseMapInfo::getEmptyKey(); + + return clang::CharUnits::fromQuantity(Quantity); + } + + static clang::CharUnits getTombstoneKey() { + clang::CharUnits::QuantityType Quantity = + DenseMapInfo::getTombstoneKey(); + + return clang::CharUnits::fromQuantity(Quantity); + } + + static unsigned getHashValue(const clang::CharUnits &CU) { + clang::CharUnits::QuantityType Quantity = CU.getQuantity(); + return DenseMapInfo::getHashValue(Quantity); + } + + static bool isEqual(const clang::CharUnits &LHS, + const clang::CharUnits &RHS) { + return LHS == RHS; + } +}; + +template <> struct isPodLike { + static const bool value = true; +}; + +} // end namespace llvm + #endif // LLVM_CLANG_AST_CHARUNITS_H