From c589098319a2a919a3fb57f1966325ea141f8b5f Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Sat, 6 Dec 2014 05:57:06 +0000 Subject: [PATCH] Reformat. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223580 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/IR/Constants.cpp | 6 +++--- lib/IR/LLVMContextImpl.h | 44 ++++++++++++++++------------------------ 2 files changed, 21 insertions(+), 29 deletions(-) diff --git a/lib/IR/Constants.cpp b/lib/IR/Constants.cpp index e0cb835c2c6..96d9510313e 100644 --- a/lib/IR/Constants.cpp +++ b/lib/IR/Constants.cpp @@ -554,8 +554,7 @@ Constant *ConstantInt::getFalse(Type *Ty) { ConstantInt::getFalse(Ty->getContext())); } - -// Get a ConstantInt from an APInt. Note that the value stored in the DenseMap +// Get a ConstantInt from an APInt. Note that the value stored in the DenseMap // as the key, is a DenseMapAPIntKeyInfo::KeyTy which has provided the // operator== and operator!= to ensure that the DenseMap doesn't attempt to // compare APInt's of different widths, which would violate an APInt class @@ -566,7 +565,8 @@ ConstantInt *ConstantInt::get(LLVMContext &Context, const APInt &V) { // get an existing value or the insertion position LLVMContextImpl *pImpl = Context.pImpl; ConstantInt *&Slot = pImpl->IntConstants[DenseMapAPIntKeyInfo::KeyTy(V, ITy)]; - if (!Slot) Slot = new ConstantInt(ITy, V); + if (!Slot) + Slot = new ConstantInt(ITy, V); return Slot; } diff --git a/lib/IR/LLVMContextImpl.h b/lib/IR/LLVMContextImpl.h index 5fd8683ccaf..7b5f14deb5c 100644 --- a/lib/IR/LLVMContextImpl.h +++ b/lib/IR/LLVMContextImpl.h @@ -48,54 +48,46 @@ class Value; struct DenseMapAPIntKeyInfo { struct KeyTy { APInt val; - Type* type; - KeyTy(const APInt& V, Type* Ty) : val(V), type(Ty) {} - bool operator==(const KeyTy& that) const { + Type *type; + KeyTy(const APInt &V, Type *Ty) : val(V), type(Ty) {} + bool operator==(const KeyTy &that) const { return type == that.type && this->val == that.val; } - bool operator!=(const KeyTy& that) const { - return !this->operator==(that); - } + bool operator!=(const KeyTy &that) const { return !this->operator==(that); } friend hash_code hash_value(const KeyTy &Key) { return hash_combine(Key.type, Key.val); } }; - static inline KeyTy getEmptyKey() { return KeyTy(APInt(1,0), nullptr); } - static inline KeyTy getTombstoneKey() { return KeyTy(APInt(1,1), nullptr); } + static inline KeyTy getEmptyKey() { return KeyTy(APInt(1, 0), nullptr); } + static inline KeyTy getTombstoneKey() { return KeyTy(APInt(1, 1), nullptr); } static unsigned getHashValue(const KeyTy &Key) { return static_cast(hash_value(Key)); } - static bool isEqual(const KeyTy &LHS, const KeyTy &RHS) { - return LHS == RHS; - } + static bool isEqual(const KeyTy &LHS, const KeyTy &RHS) { return LHS == RHS; } }; struct DenseMapAPFloatKeyInfo { struct KeyTy { APFloat val; - KeyTy(const APFloat& V) : val(V){} - bool operator==(const KeyTy& that) const { + KeyTy(const APFloat &V) : val(V) {} + bool operator==(const KeyTy &that) const { return this->val.bitwiseIsEqual(that.val); } - bool operator!=(const KeyTy& that) const { - return !this->operator==(that); - } + bool operator!=(const KeyTy &that) const { return !this->operator==(that); } friend hash_code hash_value(const KeyTy &Key) { return hash_combine(Key.val); } }; - static inline KeyTy getEmptyKey() { - return KeyTy(APFloat(APFloat::Bogus,1)); + static inline KeyTy getEmptyKey() { + return KeyTy(APFloat(APFloat::Bogus, 1)); } - static inline KeyTy getTombstoneKey() { - return KeyTy(APFloat(APFloat::Bogus,2)); + static inline KeyTy getTombstoneKey() { + return KeyTy(APFloat(APFloat::Bogus, 2)); } static unsigned getHashValue(const KeyTy &Key) { return static_cast(hash_value(Key)); } - static bool isEqual(const KeyTy &LHS, const KeyTy &RHS) { - return LHS == RHS; - } + static bool isEqual(const KeyTy &LHS, const KeyTy &RHS) { return LHS == RHS; } }; struct AnonStructTypeKeyInfo { @@ -280,9 +272,9 @@ public: typedef DenseMap IntMapTy; IntMapTy IntConstants; - - typedef DenseMap FPMapTy; + + typedef DenseMap FPMapTy; FPMapTy FPConstants; FoldingSet AttrsSet; -- 2.34.1